1 //===-- llvm/CodeGen/InstrSelectionSupport.h --------------------*- C++ -*-===//
3 // Target-independent instruction selection code. See SparcInstrSelection.cpp
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_CODEGEN_INSTR_SELECTION_SUPPORT_H
9 #define LLVM_CODEGEN_INSTR_SELECTION_SUPPORT_H
11 #include "llvm/CodeGen/MachineInstr.h"
12 #include "Support/DataTypes.h"
13 class InstructionNode;
17 //---------------------------------------------------------------------------
18 // Function GetConstantValueAsUnsignedInt
19 // Function GetConstantValueAsSignedInt
21 // Convenience functions to get the value of an integer constant, for an
22 // appropriate integer or non-integer type that can be held in a signed
23 // or unsigned integer respectively. The type of the argument must be
25 // Signed or unsigned integer
29 // isValidConstant is set to true if a valid constant was found.
30 //---------------------------------------------------------------------------
32 uint64_t GetConstantValueAsUnsignedInt (const Value *V,
33 bool &isValidConstant);
35 int64_t GetConstantValueAsSignedInt (const Value *V,
36 bool &isValidConstant);
39 //---------------------------------------------------------------------------
40 // Function: GetMemInstArgs
43 // Get the pointer value and the index vector for a memory operation
44 // (GetElementPtr, Load, or Store). If all indices of the given memory
45 // operation are constant, fold in constant indices in a chain of
46 // preceding GetElementPtr instructions (if any), and return the
47 // pointer value of the first instruction in the chain.
48 // All folded instructions are marked so no code is generated for them.
51 // Returns the pointer Value to use.
52 // Returns the resulting IndexVector in idxVec.
53 // Returns true/false in allConstantIndices if all indices are/aren't const.
54 //---------------------------------------------------------------------------
56 Value* GetMemInstArgs (InstructionNode* memInstrNode,
57 std::vector<Value*>& idxVec,
58 bool& allConstantIndices);
61 //---------------------------------------------------------------------------
62 // Function: ChooseRegOrImmed
66 //---------------------------------------------------------------------------
68 MachineOperand::MachineOperandType ChooseRegOrImmed(
71 const TargetMachine& targetMachine,
73 unsigned& getMachineRegNum,
74 int64_t& getImmedValue);
76 MachineOperand::MachineOperandType ChooseRegOrImmed(int64_t intValue,
79 const TargetMachine& target,
81 unsigned& getMachineRegNum,
82 int64_t& getImmedValue);