summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-05 05:54:46 +0000
committerChris Lattner <sabre@nondot.org>2009-10-05 05:54:46 +0000
commitfdd87907185162d3ffec237c426530d63c23bcca (patch)
tree764fe48a8294ae462f454fb0fd7f82e4f03bacca /llvm/lib/CodeGen
parent3a2e503e33efdbf723f95fc592fe62335248b078 (diff)
downloadbcm5719-llvm-fdd87907185162d3ffec237c426530d63c23bcca.tar.gz
bcm5719-llvm-fdd87907185162d3ffec237c426530d63c23bcca.zip
strength reduce a ton of type equality tests to check the typeid (Through
the new predicates I added) instead of going through a context and doing a pointer comparison. Besides being cheaper, this allows a smart compiler to turn the if sequence into a switch. llvm-svn: 83297
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp14
-rw-r--r--llvm/lib/CodeGen/ELFWriter.cpp13
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp2
3 files changed, 17 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 7e834737f01..500693971c3 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1006,7 +1006,7 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
// precision...
LLVMContext &Context = CFP->getContext();
const TargetData *TD = TM.getTargetData();
- if (CFP->getType() == Type::getDoubleTy(Context)) {
+ if (CFP->getType()->isDoubleTy()) {
double Val = CFP->getValueAPF().convertToDouble(); // for comment only
uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
if (MAI->getData64bitsDirective(AddrSpace)) {
@@ -1048,7 +1048,9 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
O << '\n';
}
return;
- } else if (CFP->getType() == Type::getFloatTy(Context)) {
+ }
+
+ if (CFP->getType()->isFloatTy()) {
float Val = CFP->getValueAPF().convertToFloat(); // for comment only
O << MAI->getData32bitsDirective(AddrSpace)
<< CFP->getValueAPF().bitcastToAPInt().getZExtValue();
@@ -1058,7 +1060,9 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
}
O << '\n';
return;
- } else if (CFP->getType() == Type::getX86_FP80Ty(Context)) {
+ }
+
+ if (CFP->getType()->isX86_FP80Ty()) {
// all long double variants are printed as hex
// api needed to prevent premature destruction
APInt api = CFP->getValueAPF().bitcastToAPInt();
@@ -1143,7 +1147,9 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
EmitZeros(TD->getTypeAllocSize(Type::getX86_FP80Ty(Context)) -
TD->getTypeStoreSize(Type::getX86_FP80Ty(Context)), AddrSpace);
return;
- } else if (CFP->getType() == Type::getPPC_FP128Ty(Context)) {
+ }
+
+ if (CFP->getType()->isPPC_FP128Ty()) {
// all long double variants are printed as hex
// api needed to prevent premature destruction
APInt api = CFP->getValueAPF().bitcastToAPInt();
diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp
index 55a2f700643..3e1ee11b216 100644
--- a/llvm/lib/CodeGen/ELFWriter.cpp
+++ b/llvm/lib/CodeGen/ELFWriter.cpp
@@ -457,16 +457,15 @@ void ELFWriter::EmitGlobalConstant(const Constant *CV, ELFSection &GblS) {
return;
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
APInt Val = CFP->getValueAPF().bitcastToAPInt();
- if (CFP->getType() == Type::getDoubleTy(CV->getContext()))
+ if (CFP->getType()->isDoubleTy())
GblS.emitWord64(Val.getZExtValue());
- else if (CFP->getType() == Type::getFloatTy(CV->getContext()))
+ else if (CFP->getType()->isFloatTy())
GblS.emitWord32(Val.getZExtValue());
- else if (CFP->getType() == Type::getX86_FP80Ty(CV->getContext())) {
- unsigned PadSize =
- TD->getTypeAllocSize(Type::getX86_FP80Ty(CV->getContext()))-
- TD->getTypeStoreSize(Type::getX86_FP80Ty(CV->getContext()));
+ else if (CFP->getType()->isX86_FP80Ty()) {
+ unsigned PadSize = TD->getTypeAllocSize(CFP->getType())-
+ TD->getTypeStoreSize(CFP->getType());
GblS.emitWordFP80(Val.getRawData(), PadSize);
- } else if (CFP->getType() == Type::getPPC_FP128Ty(CV->getContext()))
+ } else if (CFP->getType()->isPPC_FP128Ty())
llvm_unreachable("PPC_FP128Ty global emission not implemented");
return;
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 3d1c22159a5..a3560a77b65 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -239,7 +239,7 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
OS << getImm();
break;
case MachineOperand::MO_FPImmediate:
- if (getFPImm()->getType() == Type::getFloatTy(getFPImm()->getContext()))
+ if (getFPImm()->getType()->isFloatTy())
OS << getFPImm()->getValueAPF().convertToFloat();
else
OS << getFPImm()->getValueAPF().convertToDouble();
OpenPOWER on IntegriCloud