aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/MachineConstantPool.h
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-09-12 21:00:35 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-09-12 21:00:35 +0000
commitd6594ae54cfde4db4d30272192645c0a45fb9902 (patch)
tree7b89d2a0c89f9fc9bdb58acad508acd59cf3702d /include/llvm/CodeGen/MachineConstantPool.h
parentcd5731d98b15c9de236bd0dd6c9c57d9bcecbceb (diff)
downloadexternal_llvm-d6594ae54cfde4db4d30272192645c0a45fb9902.zip
external_llvm-d6594ae54cfde4db4d30272192645c0a45fb9902.tar.gz
external_llvm-d6594ae54cfde4db4d30272192645c0a45fb9902.tar.bz2
Added support for machine specific constantpool values. These are useful for
representing expressions that can only be resolved at link time, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30278 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineConstantPool.h')
-rw-r--r--include/llvm/CodeGen/MachineConstantPool.h63
1 files changed, 60 insertions, 3 deletions
diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h
index 9c729b2..b55b283 100644
--- a/include/llvm/CodeGen/MachineConstantPool.h
+++ b/include/llvm/CodeGen/MachineConstantPool.h
@@ -15,22 +15,77 @@
#ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
#define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
+#include "llvm/CodeGen/SelectionDAGCSEMap.h"
#include <vector>
#include <iosfwd>
namespace llvm {
+class AsmPrinter;
class Constant;
class TargetData;
+class TargetMachine;
+class MachineConstantPool;
+
+/// Abstract base class for all machine specific constantpool value subclasses.
+///
+class MachineConstantPoolValue {
+ const Type *Ty;
+
+public:
+ MachineConstantPoolValue(const Type *ty) : Ty(ty) {}
+ virtual ~MachineConstantPoolValue() {};
+
+ /// getType - get type of this MachineConstantPoolValue.
+ ///
+ inline const Type *getType() const { return Ty; }
+
+ virtual int getExistingMachineCPValue(MachineConstantPool *CP,
+ unsigned Alignment) = 0;
+
+ virtual void AddSelectionDAGCSEId(SelectionDAGCSEMap::NodeID *Id) = 0;
+
+ /// print - Implement operator<<...
+ ///
+ virtual void print(std::ostream &O) const = 0;
+};
+
+inline std::ostream &operator<<(std::ostream &OS,
+ const MachineConstantPoolValue &V) {
+ V.print(OS);
+ return OS;
+}
/// This class is a data container for one entry in a MachineConstantPool.
/// It contains a pointer to the value and an offset from the start of
/// the constant pool.
/// @brief An entry in a MachineConstantPool
struct MachineConstantPoolEntry {
- Constant *Val; ///< The constant itself.
- unsigned Offset; ///< The offset of the constant from the start of the pool.
- MachineConstantPoolEntry(Constant *V, unsigned O) : Val(V), Offset(O) {}
+ /// The constant itself.
+ union {
+ Constant *ConstVal;
+ MachineConstantPoolValue *MachineCPVal;
+ } Val;
+
+ /// The offset of the constant from the start of the pool. It's really
+ /// 31-bit only. The top bit is set when Val is a MachineConstantPoolValue.
+ unsigned Offset;
+
+ MachineConstantPoolEntry(Constant *V, unsigned O)
+ : Offset(O) {
+ assert((int)Offset >= 0 && "Offset is too large");
+ Val.ConstVal = V;
+ }
+ MachineConstantPoolEntry(MachineConstantPoolValue *V, unsigned O)
+ : Offset(O){
+ assert((int)Offset >= 0 && "Offset is too large");
+ Val.MachineCPVal = V;
+ Offset |= 1 << (sizeof(unsigned)*8-1);
+ }
+
+ bool isMachineConstantPoolEntry() const {
+ return (int)Offset < 0;
+ }
};
/// The MachineConstantPool class keeps track of constants referenced by a
@@ -50,6 +105,7 @@ class MachineConstantPool {
public:
/// @brief The only constructor.
MachineConstantPool(const TargetData *td) : TD(td), PoolAlignment(1) {}
+ ~MachineConstantPool();
/// getConstantPoolAlignment - Return the log2 of the alignment required by
/// the whole constant pool, of which the first element must be aligned.
@@ -58,6 +114,7 @@ public:
/// getConstantPoolIndex - Create a new entry in the constant pool or return
/// an existing one. User must specify an alignment in bytes for the object.
unsigned getConstantPoolIndex(Constant *C, unsigned Alignment);
+ unsigned getConstantPoolIndex(MachineConstantPoolValue *V,unsigned Alignment);
/// isEmpty - Return true if this constant pool contains no constants.
bool isEmpty() const { return Constants.empty(); }