Use sethi to build large immediates with zeros at the bottom
authorChris Lattner <sabre@nondot.org>
Sat, 17 Dec 2005 19:37:00 +0000 (19:37 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 17 Dec 2005 19:37:00 +0000 (19:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24779 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Sparc/SparcInstrFormats.td
lib/Target/Sparc/SparcInstrInfo.td
lib/Target/SparcV8/SparcV8InstrFormats.td
lib/Target/SparcV8/SparcV8InstrInfo.td

index 503a0ec202eb37ecb03395132f220afee0b00f89..ace4a9c6b5f919ef985f31ae3873455d3f808f8a 100644 (file)
@@ -21,11 +21,12 @@ class F2 : InstV8 {                   // Format 2 instructions
 
 // Specific F2 classes: SparcV8 manual, page 44
 //
-class F2_1<bits<3> op2Val, dag ops, string asmstr> : F2 {
+class F2_1<bits<3> op2Val, dag ops, string asmstr, list<dag> pattern> : F2 {
   bits<5>  rd;
 
   dag OperandList = ops;
   let AsmString   = asmstr;
+  let Pattern = pattern;
 
   let op2         = op2Val;
 
index 53d62d05015c87db2b69662fb1362ebe982a0ca9..bc6938b1fdeba46bf2b5920cfe8bb4a6c14ad45c 100644 (file)
@@ -39,6 +39,15 @@ def simm13  : PatLeaf<(imm), [{
   return (((int)N->getValue() << (32-13)) >> (32-13)) == (int)N->getValue();
 }]>;
 
+def HI22 : SDNodeXForm<imm, [{
+  // Transformation function: shift the immediate value down into the low bits.
+  return CurDAG->getTargetConstant((unsigned)N->getValue() >> 10, MVT::i32);
+}]>;
+
+def SETHIimm : PatLeaf<(imm), [{
+  return (((unsigned)N->getValue() >> 10) << 10) == (unsigned)N->getValue();
+}], HI22>;
+
 //===----------------------------------------------------------------------===//
 // Instructions
 //===----------------------------------------------------------------------===//
@@ -160,12 +169,13 @@ def STDFQri : F3_2<3, 0b100110,
 // Section B.9 - SETHI Instruction, p. 104
 def SETHIi: F2_1<0b100,
                  (ops IntRegs:$dst, i32imm:$src),
-                 "sethi $src, $dst">;
+                 "sethi $src, $dst",
+                 [(set IntRegs:$dst, SETHIimm:$src)]>;
 
 // Section B.10 - NOP Instruction, p. 105
 // (It's a special case of SETHI)
 let rd = 0, imm22 = 0 in
-  def NOP : F2_1<0b100, (ops), "nop">;
+  def NOP : F2_1<0b100, (ops), "nop", []>;
 
 // Section B.11 - Logical Instructions, p. 106
 def ANDrr   : F3_1<2, 0b000001,
index 503a0ec202eb37ecb03395132f220afee0b00f89..ace4a9c6b5f919ef985f31ae3873455d3f808f8a 100644 (file)
@@ -21,11 +21,12 @@ class F2 : InstV8 {                   // Format 2 instructions
 
 // Specific F2 classes: SparcV8 manual, page 44
 //
-class F2_1<bits<3> op2Val, dag ops, string asmstr> : F2 {
+class F2_1<bits<3> op2Val, dag ops, string asmstr, list<dag> pattern> : F2 {
   bits<5>  rd;
 
   dag OperandList = ops;
   let AsmString   = asmstr;
+  let Pattern = pattern;
 
   let op2         = op2Val;
 
index 53d62d05015c87db2b69662fb1362ebe982a0ca9..bc6938b1fdeba46bf2b5920cfe8bb4a6c14ad45c 100644 (file)
@@ -39,6 +39,15 @@ def simm13  : PatLeaf<(imm), [{
   return (((int)N->getValue() << (32-13)) >> (32-13)) == (int)N->getValue();
 }]>;
 
+def HI22 : SDNodeXForm<imm, [{
+  // Transformation function: shift the immediate value down into the low bits.
+  return CurDAG->getTargetConstant((unsigned)N->getValue() >> 10, MVT::i32);
+}]>;
+
+def SETHIimm : PatLeaf<(imm), [{
+  return (((unsigned)N->getValue() >> 10) << 10) == (unsigned)N->getValue();
+}], HI22>;
+
 //===----------------------------------------------------------------------===//
 // Instructions
 //===----------------------------------------------------------------------===//
@@ -160,12 +169,13 @@ def STDFQri : F3_2<3, 0b100110,
 // Section B.9 - SETHI Instruction, p. 104
 def SETHIi: F2_1<0b100,
                  (ops IntRegs:$dst, i32imm:$src),
-                 "sethi $src, $dst">;
+                 "sethi $src, $dst",
+                 [(set IntRegs:$dst, SETHIimm:$src)]>;
 
 // Section B.10 - NOP Instruction, p. 105
 // (It's a special case of SETHI)
 let rd = 0, imm22 = 0 in
-  def NOP : F2_1<0b100, (ops), "nop">;
+  def NOP : F2_1<0b100, (ops), "nop", []>;
 
 // Section B.11 - Logical Instructions, p. 106
 def ANDrr   : F3_1<2, 0b000001,