Add a flag for indirect branch instructions.
authorOwen Anderson <resistor@mac.com>
Mon, 12 Nov 2007 07:39:39 +0000 (07:39 +0000)
committerOwen Anderson <resistor@mac.com>
Mon, 12 Nov 2007 07:39:39 +0000 (07:39 +0000)
Target maintainers: please check that the instructions for your target are correctly marked.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44012 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetInstrInfo.h
lib/Target/ARM/ARMInstrInfo.td
lib/Target/Alpha/AlphaInstrInfo.td
lib/Target/PowerPC/PPCInstrInfo.td
lib/Target/Target.td
lib/Target/X86/X86InstrInfo.td
lib/Target/X86/X86InstrX86-64.td
utils/TableGen/CodeGenInstruction.h
utils/TableGen/CodeGenTarget.cpp
utils/TableGen/InstrInfoEmitter.cpp

index 1432b5f2159241589fa69240fe26364e99fefe47..a0596e47c6e2a68e0673dc78b81c5b54d8b7508b 100644 (file)
@@ -48,6 +48,7 @@ const unsigned M_BARRIER_FLAG          = 1 << 3;
 const unsigned M_DELAY_SLOT_FLAG       = 1 << 4;
 const unsigned M_LOAD_FLAG             = 1 << 5;
 const unsigned M_STORE_FLAG            = 1 << 6;
+const unsigned M_INDIRECT_FLAG         = 1 << 7;
 
 // M_CONVERTIBLE_TO_3_ADDR - This is a 2-address instruction which can be
 // changed into a 3-address instruction if the first two operands cannot be
@@ -237,6 +238,10 @@ public:
     return get(Opcode).Flags & M_BRANCH_FLAG;
   }
   
+  bool isIndirectBranch(MachineOpCode Opcode) const {
+    return get(Opcode).Flags & M_INDIRECT_FLAG;
+  }
+  
   /// isBarrier - Returns true if the specified instruction stops control flow
   /// from executing the instruction immediately following it.  Examples include
   /// unconditional branches and return instructions.
index 8e59848611f3a31869aad774d01c3ed73cf29ae4..8ff610eec55a5304161be1d0c17fcc668f5357ee 100644 (file)
@@ -773,7 +773,7 @@ let isBranch = 1, isTerminator = 1 in {
     def B : AXI<0xA, (outs), (ins brtarget:$target), Branch, "b $target",
                 [(br bb:$target)]>;
 
-  let isNotDuplicable = 1 in {
+  let isNotDuplicable = 1, isIndirectBranch = 1 in {
   def BR_JTr : JTI<0x0, (outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
                     "mov pc, $target \n$jt",
                     [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
index 602ab7aa8a00790f57d1a1cbb9d4c450c15ed7b6..f73875062ab7175ecfa3d59a474e37dcdcd3c80e 100644 (file)
@@ -374,8 +374,7 @@ let isReturn = 1, isTerminator = 1, Ra = 31, Rb = 26, disp = 1, Uses = [R26] in
   def RETDAGp : MbrpForm< 0x1A, 0x02, (ops), "ret $$31,($$26),1", [(retflag)], s_jsr>; //Return from subroutine
 }
 
-let isBranch = 1, isTerminator = 1, isBarrier = 1,
-Ra = 31, disp = 0 in
+let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1, Ra = 31, disp = 0 in
 def JMP : MbrpForm< 0x1A, 0x00, (ops GPRC:$RS), "jmp $$31,($RS),0", 
           [(brind GPRC:$RS)], s_jsr>; //Jump
 
index 6a08cea512e02b76e55e07acd20db0174f48fa93..77e00e5776136e0dba9b27c88878152e867abb36 100644 (file)
@@ -369,7 +369,8 @@ let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
     def BLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$p),
                           "b${p:cc}lr ${p:reg}", BrB, 
                           [(retflag)]>;
-  def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>;
+  let isBranch = 1, isIndirectBranch = 1 in
+    def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>;
 }
 
 
index 169953f0eaff25b08943848cafbb4a2c319b51a5..4c28f99b6f2430927a8ff69892a1787be7e91f80 100644 (file)
@@ -187,6 +187,7 @@ class Instruction {
   // instruction.
   bit isReturn     = 0;     // Is this instruction a return instruction?
   bit isBranch     = 0;     // Is this instruction a branch instruction?
+  bit isIndirectBranch = 0; // Is this instruction an indirect branch?
   bit isBarrier    = 0;     // Can control flow fall through this instruction?
   bit isCall       = 0;     // Is this instruction a call instruction?
   bit isLoad       = 0;     // Is this instruction a load instruction?
index e9f9bd6c1c4ab6c38ef83b5230fe868b4f6dc7b9..43ad9b047288f0a722b3323fd5b175fff0009117 100644 (file)
@@ -294,11 +294,11 @@ let isBranch = 1, isTerminator = 1 in
   class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
         I<opcode, RawFrm, (outs), ins, asm, pattern>;
 
-// Indirect branches
 let isBranch = 1, isBarrier = 1 in
   def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
 
-let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
+// Indirect branches
+let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
   def JMP32r     : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
                      [(brind GR32:$dst)]>;
   def JMP32m     : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
index 42863d49309cdf05db5de15c3fba2aef7798f7ce..2d9ca97e21471d9d9cff31f748e8ff4dad602590 100644 (file)
@@ -120,7 +120,7 @@ let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
                  []>;     
 
 // Branches
-let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
+let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
   def JMP64r     : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
                      [(brind GR64:$dst)]>;
   def JMP64m     : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
index 6abe972880d3e482e30022140a4b961877fb572b..245b38e0493c6d7457ddbb2ba585b1bd67689644 100644 (file)
@@ -87,6 +87,7 @@ namespace llvm {
     // Various boolean values we track for the instruction.
     bool isReturn;
     bool isBranch;
+    bool isIndirectBranch;
     bool isBarrier;
     bool isCall;
     bool isLoad;
index ea96cf4bd2797a5e902769a7d294e0c04c5617b8..4de05b2f83d3396d21da4411662634ec349b4e6b 100644 (file)
@@ -379,6 +379,7 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
 
   isReturn     = R->getValueAsBit("isReturn");
   isBranch     = R->getValueAsBit("isBranch");
+  isIndirectBranch = R->getValueAsBit("isIndirectBranch");
   isBarrier    = R->getValueAsBit("isBarrier");
   isCall       = R->getValueAsBit("isCall");
   isLoad       = R->getValueAsBit("isLoad");
index ca8d30f0c05ab489f97e7d752c8cbedc569a7197..d371934bbbe69cbc95d6f165c9f2ac42bb3068f6 100644 (file)
@@ -237,6 +237,7 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
   // Emit all of the target indepedent flags...
   if (Inst.isReturn)     OS << "|M_RET_FLAG";
   if (Inst.isBranch)     OS << "|M_BRANCH_FLAG";
+  if (Inst.isIndirectBranch) OS << "|M_INDIRECT_FLAG";
   if (Inst.isBarrier)    OS << "|M_BARRIER_FLAG";
   if (Inst.hasDelaySlot) OS << "|M_DELAY_SLOT_FLAG";
   if (Inst.isCall)       OS << "|M_CALL_FLAG";