From 275ca43ee3efd5513659ea377de8f596397f6f82 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 5 May 2016 15:29:47 +0000 Subject: [PATCH] [Hexagon] Handle operand type differences for A2_tfrpi The instruction A2_tfrpi has a 64-bit operand, while the corresponding intrinsic takes a 32-bit value. The actual value has only 8 significant bits, so the difference is only in the type used to represent it. In order to map the intrinsic to the instruction, the operand needs to be extended to the correct type. llvm-svn: 268635 --- include/llvm/IR/IntrinsicsHexagon.td | 2 +- lib/Target/Hexagon/HexagonIntrinsics.td | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/llvm/IR/IntrinsicsHexagon.td b/include/llvm/IR/IntrinsicsHexagon.td index bdc82d19e9f..6519f051dee 100644 --- a/include/llvm/IR/IntrinsicsHexagon.td +++ b/include/llvm/IR/IntrinsicsHexagon.td @@ -2998,7 +2998,7 @@ Hexagon_di_di_Intrinsic<"HEXAGON_A2_tfrp">; // BUILTIN_INFO(HEXAGON.A2_tfrpi,DI_ftype_SI,1) // def int_hexagon_A2_tfrpi : -Hexagon_di_di_Intrinsic<"HEXAGON_A2_tfrpi">; +Hexagon_di_si_Intrinsic<"HEXAGON_A2_tfrpi">; // // BUILTIN_INFO(HEXAGON.A2_zxtb,SI_ftype_SI,1) // diff --git a/lib/Target/Hexagon/HexagonIntrinsics.td b/lib/Target/Hexagon/HexagonIntrinsics.td index 0ec0a44df65..a319dd4f978 100644 --- a/lib/Target/Hexagon/HexagonIntrinsics.td +++ b/lib/Target/Hexagon/HexagonIntrinsics.td @@ -744,7 +744,22 @@ def : Pat <(int_hexagon_A2_tfrih I32:$Rs, u16_0ImmPred:$Is), // Transfer Register/immediate. def : T_R_pat ; def : T_I_pat ; -def : T_I_pat ; + +def ImmExt64: SDNodeXFormgetSExtValue(); + return CurDAG->getTargetConstant(V, SDLoc(N), MVT::i64); +}]>; + +// A2_tfrpi has an operand of type i64. This is necessary, since it is +// generated from "(set I64:$Rd, imm)". That pattern would not appear +// in the DAG, if the immediate was not a 64-bit value. +// The builtin for A2_tfrpi, on the other hand, takes a 32-bit value, +// which makes it impossible to simply replace it with the instruction. +// To connect the builtin with the instruction, the builtin's operand +// needs to be extended to the right type. + +def : Pat<(int_hexagon_A2_tfrpi imm:$Is), + (A2_tfrpi (ImmExt64 $Is))>; // Assembler mapped from Rdd32=Rss32 to Rdd32=combine(Rss.H32,Rss.L32) def : Pat<(int_hexagon_A2_tfrp I64:$src),