[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Nov 21 00:25:21 PST 2005
Changes in directory llvm/lib/CodeGen:
AsmPrinter.cpp updated: 1.28 -> 1.29
---
Log message:
Allow target to customize directive used to switch to arbitrary section in SwitchSection,
add generic constant pool emitter
---
Diffs of the changes: (+28 -1)
AsmPrinter.cpp | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletion(-)
Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.28 llvm/lib/CodeGen/AsmPrinter.cpp:1.29
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.28 Mon Nov 21 02:13:27 2005
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Nov 21 02:25:09 2005
@@ -14,6 +14,7 @@
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/Constants.h"
#include "llvm/Module.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetMachine.h"
@@ -26,7 +27,7 @@
std::string NS;
if (GV && GV->hasSection())
- NS = ".section " + GV->getSection();
+ NS = SwitchToSectionDirective + GV->getSection();
else
NS = NewSection;
@@ -54,6 +55,32 @@
IncrementFunctionNumber();
}
+/// EmitConstantPool - Print to the current output stream assembly
+/// representations of the constants in the constant pool MCP. This is
+/// used to print out constants which have been "spilled to memory" by
+/// the code generator.
+///
+void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
+ const std::vector<Constant*> &CP = MCP->getConstants();
+ if (CP.empty()) return;
+ const TargetData &TD = TM.getTargetData();
+
+ SwitchSection(ConstantPoolSection, 0);
+ for (unsigned i = 0, e = CP.size(); i != e; ++i) {
+ // FIXME: force doubles to be naturally aligned. We should handle this
+ // more correctly in the future.
+ unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType());
+ if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
+
+ EmitAlignment(Alignment);
+ O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
+ << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
+ EmitGlobalConstant(CP[i]);
+ }
+}
+
+
+
// EmitAlignment - Emit an alignment directive to the specified power of two.
void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {
if (GV && GV->getAlignment())
More information about the llvm-commits
mailing list