Remove internal helper fn
[oota-llvm.git] / include / llvm / CodeGen / InstrSelectionSupport.h
1 //===-- llvm/CodeGen/InstrSelectionSupport.h --------------------*- C++ -*-===//
2 //
3 //  Target-independent instruction selection code.  See SparcInstrSelection.cpp
4 //  for usage.
5 //      
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_CODEGEN_INSTR_SELECTION_SUPPORT_H
9 #define LLVM_CODEGEN_INSTR_SELECTION_SUPPORT_H
10
11 #include "llvm/CodeGen/MachineInstr.h"
12 #include "Support/DataTypes.h"
13 class InstructionNode;
14 class TargetMachine;
15 class Instruction;
16
17 //---------------------------------------------------------------------------
18 // Function GetConstantValueAsUnsignedInt
19 // Function GetConstantValueAsSignedInt
20 // 
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
24 // the following:
25 //      Signed or unsigned integer
26 //      Boolean
27 //      Pointer
28 // 
29 // isValidConstant is set to true if a valid constant was found.
30 //---------------------------------------------------------------------------
31
32 uint64_t        GetConstantValueAsUnsignedInt   (const Value *V,
33                                                  bool &isValidConstant);
34
35 int64_t         GetConstantValueAsSignedInt     (const Value *V,
36                                                  bool &isValidConstant);
37
38
39 //---------------------------------------------------------------------------
40 // Function: GetMemInstArgs
41 // 
42 // Purpose:
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.
49 //
50 // Return values:
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 //---------------------------------------------------------------------------
55
56 Value*          GetMemInstArgs  (InstructionNode* memInstrNode,
57                                  std::vector<Value*>& idxVec,
58                                  bool& allConstantIndices);
59
60
61 //---------------------------------------------------------------------------
62 // Function: ChooseRegOrImmed
63 // 
64 // Purpose:
65 // 
66 //---------------------------------------------------------------------------
67
68 MachineOperand::MachineOperandType ChooseRegOrImmed(
69                                          Value* val,
70                                          MachineOpCode opCode,
71                                          const TargetMachine& targetMachine,
72                                          bool canUseImmed,
73                                          unsigned& getMachineRegNum,
74                                          int64_t& getImmedValue);
75
76 MachineOperand::MachineOperandType ChooseRegOrImmed(int64_t intValue,
77                                          bool isSigned,
78                                          MachineOpCode opCode,
79                                          const TargetMachine& target,
80                                          bool canUseImmed,
81                                          unsigned& getMachineRegNum,
82                                          int64_t& getImmedValue);
83
84 #endif