From f60b1f479f82e012fa4345dcfed757e306d5de26 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Wed, 17 Oct 2001 23:59:09 +0000 Subject: [PATCH] 1. Add a bottom-up pass on BURG trees that is used to fix constant operands. 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 | 5 ++- include/llvm/CodeGen/InstrSelectionSupport.h | 38 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/include/llvm/CodeGen/InstrSelection.h b/include/llvm/CodeGen/InstrSelection.h index 632d37c85b7..8010614d67f 100644 --- a/include/llvm/CodeGen/InstrSelection.h +++ b/include/llvm/CodeGen/InstrSelection.h @@ -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) diff --git a/include/llvm/CodeGen/InstrSelectionSupport.h b/include/llvm/CodeGen/InstrSelectionSupport.h index 5253ef8cc45..7d11e206b51 100644 --- a/include/llvm/CodeGen/InstrSelectionSupport.h +++ b/include/llvm/CodeGen/InstrSelectionSupport.h @@ -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 FixConstantOperandsForInstr (Instruction* vmInstr, + MachineInstr* minstr, + TargetMachine& target); + + //**************************************************************************/ #endif