[llvm-commits] [llvm] r93994 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Tue Jan 19 23:33:30 PST 2010
Author: lattner
Date: Wed Jan 20 01:33:29 2010
New Revision: 93994
URL: http://llvm.org/viewvc/llvm-project?rev=93994&view=rev
Log:
inline and radically simplify printDataDirective. It will eventually
go completely away.
Modified:
llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93994&r1=93993&r2=93994&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Jan 20 01:33:29 2010
@@ -413,10 +413,6 @@
const MachineBasicBlock *MBB,
unsigned uid) const;
- /// printDataDirective - This method prints the asm directive for the
- /// specified type.
- void printDataDirective(const Type *type, unsigned AddrSpace = 0);
-
/// printVisibility - This prints visibility information about symbol, if
/// this is suported by the target.
void printVisibility(const MCSymbol *Sym, unsigned Visibility) const;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93994&r1=93993&r2=93994&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Jan 20 01:33:29 2010
@@ -1248,8 +1248,24 @@
if (const ConstantVector *V = dyn_cast<ConstantVector>(CV))
return EmitGlobalConstantVector(V, AddrSpace, *this);
- // ConstantExpr case.
- printDataDirective(CV->getType(), AddrSpace);
+ // Otherwise, it must be a ConstantExpr. Emit the data directive, then emit
+ // the expression value.
+ switch (TM.getTargetData()->getTypeAllocSize(CV->getType())) {
+ case 0: return;
+ case 1: O << MAI->getData8bitsDirective(AddrSpace); break;
+ case 2: O << MAI->getData16bitsDirective(AddrSpace); break;
+ case 4: O << MAI->getData32bitsDirective(AddrSpace); break;
+ case 8:
+ if (const char *Dir = MAI->getData64bitsDirective(AddrSpace)) {
+ O << Dir;
+ break;
+ }
+ // FALL THROUGH.
+ default:
+ llvm_unreachable("Target cannot handle given data directive width!");
+ return;
+ }
+
EmitConstantValueOnly(CV);
O << '\n';
}
@@ -1700,49 +1716,6 @@
<< '_' << uid << '_' << uid2 << '\n';
}
-/// printDataDirective - This method prints the asm directive for the
-/// specified type.
-void AsmPrinter::printDataDirective(const Type *type, unsigned AddrSpace) {
- const TargetData *TD = TM.getTargetData();
- switch (type->getTypeID()) {
- case Type::FloatTyID: case Type::DoubleTyID:
- case Type::X86_FP80TyID: case Type::FP128TyID: case Type::PPC_FP128TyID:
- assert(0 && "Should have already output floating point constant.");
- default:
- assert(0 && "Can't handle printing this type of thing");
- case Type::IntegerTyID: {
- unsigned BitWidth = cast<IntegerType>(type)->getBitWidth();
- if (BitWidth <= 8)
- O << MAI->getData8bitsDirective(AddrSpace);
- else if (BitWidth <= 16)
- O << MAI->getData16bitsDirective(AddrSpace);
- else if (BitWidth <= 32)
- O << MAI->getData32bitsDirective(AddrSpace);
- else if (BitWidth <= 64) {
- assert(MAI->getData64bitsDirective(AddrSpace) &&
- "Target cannot handle 64-bit constant exprs!");
- O << MAI->getData64bitsDirective(AddrSpace);
- } else {
- llvm_unreachable("Target cannot handle given data directive width!");
- }
- break;
- }
- case Type::PointerTyID:
- if (TD->getPointerSize() == 8) {
- assert(MAI->getData64bitsDirective(AddrSpace) &&
- "Target cannot handle 64-bit pointer exprs!");
- O << MAI->getData64bitsDirective(AddrSpace);
- } else if (TD->getPointerSize() == 2) {
- O << MAI->getData16bitsDirective(AddrSpace);
- } else if (TD->getPointerSize() == 1) {
- O << MAI->getData8bitsDirective(AddrSpace);
- } else {
- O << MAI->getData32bitsDirective(AddrSpace);
- }
- break;
- }
-}
-
void AsmPrinter::printVisibility(const MCSymbol *Sym,
unsigned Visibility) const {
if (Visibility == GlobalValue::HiddenVisibility) {
Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93994&r1=93993&r2=93994&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jan 20 01:33:29 2010
@@ -170,7 +170,12 @@
/// EmitMachineConstantPoolValue - Print a machine constantpool value to
/// the .s file.
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
- printDataDirective(MCPV->getType());
+ switch (TM.getTargetData()->getTypeAllocSize(MCPV->getType())) {
+ case 1: O << MAI->getData8bitsDirective(0); break;
+ case 2: O << MAI->getData16bitsDirective(0); break;
+ case 4: O << MAI->getData32bitsDirective(0); break;
+ default: assert(0 && "Unknown CPV size");
+ }
ARMConstantPoolValue *ACPV = static_cast<ARMConstantPoolValue*>(MCPV);
SmallString<128> TmpNameStr;
More information about the llvm-commits
mailing list