[llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h MachineInstrBuilder.h

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 29 19:49:00 PST 2002


Changes in directory llvm/include/llvm/CodeGen:

MachineInstr.h updated: 1.82 -> 1.83
MachineInstrBuilder.h updated: 1.3 -> 1.4

---
Log message:

Allow BuildMI that helps automate construction of SSA information


---
Diffs of the changes:

Index: llvm/include/llvm/CodeGen/MachineInstr.h
diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.82 llvm/include/llvm/CodeGen/MachineInstr.h:1.83
--- llvm/include/llvm/CodeGen/MachineInstr.h:1.82	Tue Oct 29 18:46:48 2002
+++ llvm/include/llvm/CodeGen/MachineInstr.h	Tue Oct 29 19:48:41 2002
@@ -372,10 +372,11 @@
 
   /// addRegOperand - Add a symbolic virtual register reference...
   ///
-  void addRegOperand(int reg) {
+  void addRegOperand(int reg, bool isDef = false) {
     assert(!OperandsComplete() &&
            "Trying to add an operand to a machine instr that is already done!");
-    operands.push_back(MachineOperand(reg, MachineOperand::MO_VirtualRegister));
+    operands.push_back(MachineOperand(reg, MachineOperand::MO_VirtualRegister,
+                                      isDef));
   }
 
   /// addPCDispOperand - Add a PC relative displacement operand to the MI


Index: llvm/include/llvm/CodeGen/MachineInstrBuilder.h
diff -u llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.3 llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.4
--- llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.3	Tue Oct 29 17:18:23 2002
+++ llvm/include/llvm/CodeGen/MachineInstrBuilder.h	Tue Oct 29 19:48:41 2002
@@ -29,8 +29,8 @@
 
   /// addReg - Add a new virtual register operand...
   ///
-  MachineInstrBuilder &addReg(int RegNo) {
-    MI->addRegOperand(RegNo);
+  MachineInstrBuilder &addReg(int RegNo, bool isDef = false) {
+    MI->addRegOperand(RegNo, isDef);
     return *this;
   }
 
@@ -72,15 +72,31 @@
 };
 
 /// BuildMI - Builder interface.  Specify how to create the initial instruction
-/// itself.
+/// itself.  NumOperands is the number of operands to the machine instruction to
+/// allow for memory efficient representation of machine instructions.
 ///
 inline MachineInstrBuilder BuildMI(MachineOpCode Opcode, unsigned NumOperands) {
   return MachineInstrBuilder(new MachineInstr(Opcode, NumOperands, true, true));
 }
 
+/// BuildMI - This version of the builder inserts the built MachineInstr into
+/// the specified MachineBasicBlock.
+///
 inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, MachineOpCode Opcode,
                                    unsigned NumOperands) {
   return MachineInstrBuilder(new MachineInstr(BB, Opcode, NumOperands));
+}
+
+/// BuildMI - This version of the builder inserts the built MachineInstr into
+/// the specified MachineBasicBlock, and also sets up the first "operand" as a
+/// destination virtual register.  NumOperands is the number of additional add*
+/// calls that are expected, it does not include the destination register.
+///
+inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, MachineOpCode Opcode,
+                                   unsigned NumOperands, unsigned DestReg) {
+  return MachineInstrBuilder(new MachineInstr(BB, Opcode,
+                                              NumOperands+1)).addReg(DestReg,
+                                                                     true);
 }
 
 #endif





More information about the llvm-commits mailing list