[llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h MachineConstantPool.h SelectionDAG.h SelectionDAGCSEMap.h SelectionDAGNodes.h
Evan Cheng
evan.cheng at apple.com
Tue Sep 12 13:59:36 PDT 2006
Changes in directory llvm/include/llvm/CodeGen:
AsmPrinter.h updated: 1.47 -> 1.48
MachineConstantPool.h updated: 1.17 -> 1.18
SelectionDAG.h updated: 1.129 -> 1.130
SelectionDAGCSEMap.h updated: 1.7 -> 1.8
SelectionDAGNodes.h updated: 1.145 -> 1.146
---
Log message:
Added support for machine specific constantpool values. These are useful for
representing expressions that can only be resolved at link time, etc.
---
Diffs of the changes: (+123 -10)
AsmPrinter.h | 9 ++++++-
MachineConstantPool.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++---
SelectionDAG.h | 9 ++++++-
SelectionDAGCSEMap.h | 1
SelectionDAGNodes.h | 51 ++++++++++++++++++++++++++++++++++++----
5 files changed, 123 insertions(+), 10 deletions(-)
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.47 llvm/include/llvm/CodeGen/AsmPrinter.h:1.48
--- llvm/include/llvm/CodeGen/AsmPrinter.h:1.47 Thu Sep 7 17:06:40 2006
+++ llvm/include/llvm/CodeGen/AsmPrinter.h Tue Sep 12 15:59:22 2006
@@ -24,6 +24,7 @@
class ConstantArray;
class GlobalVariable;
class MachineConstantPoolEntry;
+ class MachineConstantPoolValue;
class Mangler;
class TargetAsmInfo;
@@ -174,6 +175,8 @@
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
///
void EmitGlobalConstant(const Constant* CV);
+
+ virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
/// printInlineAsm - This method formats and prints the specified machine
/// instruction that is an inline asm.
@@ -188,7 +191,11 @@
/// printSetLabel - This method prints a set label for the specified
/// MachineBasicBlock
void printSetLabel(unsigned uid, const MachineBasicBlock *MBB) const;
-
+
+ /// printDataDirective - This method prints the asm directive for the
+ /// specified type.
+ void printDataDirective(const Type *type);
+
private:
void EmitXXStructorList(Constant *List);
void EmitConstantPool(unsigned Alignment, const char *Section,
Index: llvm/include/llvm/CodeGen/MachineConstantPool.h
diff -u llvm/include/llvm/CodeGen/MachineConstantPool.h:1.17 llvm/include/llvm/CodeGen/MachineConstantPool.h:1.18
--- llvm/include/llvm/CodeGen/MachineConstantPool.h:1.17 Mon May 15 11:12:01 2006
+++ llvm/include/llvm/CodeGen/MachineConstantPool.h Tue Sep 12 15:59:22 2006
@@ -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 @@
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 @@
/// 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(); }
Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.129 llvm/include/llvm/CodeGen/SelectionDAG.h:1.130
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.129 Wed Aug 30 00:56:52 2006
+++ llvm/include/llvm/CodeGen/SelectionDAG.h Tue Sep 12 15:59:22 2006
@@ -15,7 +15,6 @@
#ifndef LLVM_CODEGEN_SELECTIONDAG_H
#define LLVM_CODEGEN_SELECTIONDAG_H
-#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/SelectionDAGCSEMap.h"
#include "llvm/ADT/ilist"
@@ -30,6 +29,7 @@
class TargetMachine;
class MachineDebugInfo;
class MachineFunction;
+ class MachineConstantPoolValue;
/// SelectionDAG class - This is used to represent a portion of an LLVM function
/// in a low-level Data Dependence DAG representation suitable for instruction
@@ -167,6 +167,13 @@
unsigned Align = 0, int Offset = 0) {
return getConstantPool(C, VT, Align, Offset, true);
}
+ SDOperand getConstantPool(MachineConstantPoolValue *C, MVT::ValueType VT,
+ unsigned Align = 0, int Offs = 0, bool isT=false);
+ SDOperand getTargetConstantPool(MachineConstantPoolValue *C,
+ MVT::ValueType VT, unsigned Align = 0,
+ int Offset = 0) {
+ return getConstantPool(C, VT, Align, Offset, true);
+ }
SDOperand getBasicBlock(MachineBasicBlock *MBB);
SDOperand getExternalSymbol(const char *Sym, MVT::ValueType VT);
SDOperand getTargetExternalSymbol(const char *Sym, MVT::ValueType VT);
Index: llvm/include/llvm/CodeGen/SelectionDAGCSEMap.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGCSEMap.h:1.7 llvm/include/llvm/CodeGen/SelectionDAGCSEMap.h:1.8
--- llvm/include/llvm/CodeGen/SelectionDAGCSEMap.h:1.7 Tue Aug 15 14:11:05 2006
+++ llvm/include/llvm/CodeGen/SelectionDAGCSEMap.h Tue Sep 12 15:59:22 2006
@@ -16,6 +16,7 @@
#define LLVM_CODEGEN_SELECTIONDAGCSEMAP_H
#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/SelectionDAGNodes.h"
namespace llvm {
class SDNode;
Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.145 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.146
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.145 Sat Sep 9 00:55:44 2006
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Tue Sep 12 15:59:22 2006
@@ -19,11 +19,11 @@
#ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
#define LLVM_CODEGEN_SELECTIONDAGNODES_H
-#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Value.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
@@ -32,6 +32,7 @@
class SelectionDAG;
class GlobalValue;
class MachineBasicBlock;
+class MachineConstantPoolValue;
class SDNode;
template <typename T> struct simplify_type;
template <typename T> struct ilist_traits;
@@ -1145,7 +1146,10 @@
};
class ConstantPoolSDNode : public SDNode {
- Constant *C;
+ union {
+ Constant *ConstVal;
+ MachineConstantPoolValue *MachineCPVal;
+ } Val;
int Offset;
unsigned Alignment;
protected:
@@ -1153,20 +1157,57 @@
ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT,
int o=0)
: SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
- C(c), Offset(o), Alignment(0) {}
+ Offset(o), Alignment(0) {
+ assert((int)Offset >= 0 && "Offset is too large");
+ Val.ConstVal = c;
+ }
ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o,
unsigned Align)
: SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
- C(c), Offset(o), Alignment(Align) {}
+ Offset(o), Alignment(Align) {
+ assert((int)Offset >= 0 && "Offset is too large");
+ Val.ConstVal = c;
+ }
+ ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
+ MVT::ValueType VT, int o=0)
+ : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
+ Offset(o), Alignment(0) {
+ assert((int)Offset >= 0 && "Offset is too large");
+ Val.MachineCPVal = v;
+ Offset |= 1 << (sizeof(unsigned)*8-1);
+ }
+ ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
+ MVT::ValueType VT, int o, unsigned Align)
+ : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
+ Offset(o), Alignment(Align) {
+ assert((int)Offset >= 0 && "Offset is too large");
+ Val.MachineCPVal = v;
+ Offset |= 1 << (sizeof(unsigned)*8-1);
+ }
public:
- Constant *get() const { return C; }
+ bool isMachineConstantPoolEntry() const {
+ return (int)Offset < 0;
+ }
+
+ Constant *getConstVal() const {
+ assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
+ return Val.ConstVal;
+ }
+
+ MachineConstantPoolValue *getMachineCPVal() const {
+ assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
+ return Val.MachineCPVal;
+ }
+
int getOffset() const { return Offset; }
// Return the alignment of this constant pool object, which is either 0 (for
// default alignment) or log2 of the desired value.
unsigned getAlignment() const { return Alignment; }
+ const Type *getType() const;
+
static bool classof(const ConstantPoolSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::ConstantPool ||
More information about the llvm-commits
mailing list