1. Add a bottom-up pass on BURG trees that is used to fix constant operands.
authorVikram S. Adve <vadve@cs.uiuc.edu>
Wed, 17 Oct 2001 23:59:09 +0000 (23:59 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Wed, 17 Oct 2001 23:59:09 +0000 (23:59 +0000)
  Needs to be bottom up because constant values may be forward-substituted
   to their uses (i.e., into the parent in the BURG tree).
2. Move most of the constant-fixup code into machine-indepedent file
   InstrSelectionSupport.cpp.

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

include/llvm/CodeGen/InstrSelection.h
include/llvm/CodeGen/InstrSelectionSupport.h

index 632d37c85b763d2dd10fdf4f006c245584bbc707..8010614d67f8609bebf3dd12dbed8b6bd52ab568 100644 (file)
@@ -29,6 +29,8 @@ class TargetMachine;
 
 const unsigned MAX_INSTR_PER_VMINSTR = 8;
 
+const Instruction::OtherOps TMP_INSTRUCTION_OPCODE = Instruction::UserOp1;
+
 extern unsigned        GetInstructionsByRule   (InstructionNode* subtreeRoot,
                                         int ruleForNode,
                                         short* nts,
@@ -74,7 +76,8 @@ public:
   TmpInstruction(OtherOps Opcode, Value *S1, Value* S2, const string &Name = "")
     : Instruction(S1->getType(), Opcode, Name)
   {
-    assert(Opcode == UserOp1 && "Tmp instruction opcode invalid!");
+    assert(Opcode == TMP_INSTRUCTION_OPCODE &&
+           "Tmp instruction opcode invalid!");
     Operands.reserve(S2? 2 : 1);
     Operands.push_back(Use(S1, this));
     if (S2)
index 5253ef8cc45e37b3e2cae259228c60260fb7ec8c..7d11e206b519159e1ef5f5039566f47ac42a16be 100644 (file)
@@ -27,6 +27,23 @@ class TargetMachine;
 //************************ Exported Functions ******************************/
 
 
+//---------------------------------------------------------------------------
+// Function GetConstantValueAsSignedInt
+// 
+// Convenience function to get the value of an integer constant, for an
+// appropriate integer or non-integer type that can be held in an integer.
+// The type of the argument must be the following:
+//      Signed or unsigned integer
+//      Boolean
+//      Pointer
+// 
+// isValidConstant is set to true if a valid constant was found.
+//---------------------------------------------------------------------------
+
+int64_t         GetConstantValueAsSignedInt     (const Value *V,
+                                                 bool &isValidConstant);
+
+
 //---------------------------------------------------------------------------
 // Function: FoldGetElemChain
 // 
@@ -97,6 +114,27 @@ MachineOperand::MachineOperandType
                                          unsigned int& getMachineRegNum,
                                          int64_t& getImmedValue);
 
+
+//---------------------------------------------------------------------------
+// Function: FixConstantOperandsForInstr
+// 
+// Purpose:
+// Special handling for constant operands of a machine instruction
+// -- if the constant is 0, use the hardwired 0 register, if any;
+// -- if the constant fits in the IMMEDIATE field, use that field;
+// -- else create instructions to put the constant into a register, either
+//    directly or by loading explicitly from the constant pool.
+// 
+// In the first 2 cases, the operand of `minstr' is modified in place.
+// Returns a vector of machine instructions generated for operands that
+// fall under case 3; these must be inserted before `minstr'.
+//---------------------------------------------------------------------------
+
+vector<MachineInstr*> FixConstantOperandsForInstr (Instruction* vmInstr,
+                                                   MachineInstr* minstr,
+                                                   TargetMachine& target);
+
+
 //**************************************************************************/
 
 #endif