aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-12-15 08:02:15 +0000
committerChris Lattner <sabre@nondot.org>2002-12-15 08:02:15 +0000
commit6b993ccfe5449e780c90fa081e139600d4d20754 (patch)
tree10ef231a83266d1069939bd10e9c2e5fca31be4f
parentd909683591de7eb7d57edc1a03f6749fbc2f6840 (diff)
downloadexternal_llvm-6b993ccfe5449e780c90fa081e139600d4d20754.tar.gz
external_llvm-6b993ccfe5449e780c90fa081e139600d4d20754.tar.bz2
external_llvm-6b993ccfe5449e780c90fa081e139600d4d20754.zip
Add support to cast from a bool type
Add support for boolean constants add getClassB method git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5034 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/InstSelectSimple.cpp18
-rw-r--r--lib/Target/X86/X86ISelSimple.cpp18
2 files changed, 24 insertions, 12 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp
index 4a44dbf419..c436156561 100644
--- a/lib/Target/X86/InstSelectSimple.cpp
+++ b/lib/Target/X86/InstSelectSimple.cpp
@@ -273,6 +273,12 @@ static inline TypeClass getClass(const Type *Ty) {
}
}
+// getClassB - Just like getClass, but treat boolean values as bytes.
+static inline TypeClass getClassB(const Type *Ty) {
+ if (Ty == Type::BoolTy) return cByte;
+ return getClass(Ty);
+}
+
/// copyConstantToRegister - Output the instructions required to put the
/// specified constant into the specified register.
@@ -292,14 +298,16 @@ void ISel::copyConstantToRegister(Constant *C, unsigned R,
}
if (C->getType()->isIntegral()) {
- unsigned Class = getClass(C->getType());
+ unsigned Class = getClassB(C->getType());
assert(Class != 3 && "Type not handled yet!");
static const unsigned IntegralOpcodeTab[] = {
X86::MOVir8, X86::MOVir16, X86::MOVir32
};
- if (C->getType()->isSigned()) {
+ if (C->getType() == Type::BoolTy) {
+ BMI(MBB, IP, X86::MOVir8, 1, R).addZImm(C == ConstantBool::True);
+ } else if (C->getType()->isSigned()) {
ConstantSInt *CSI = cast<ConstantSInt>(C);
BMI(MBB, IP, IntegralOpcodeTab[Class], 1, R).addSImm(CSI->getValue());
} else {
@@ -348,9 +356,7 @@ void ISel::SelectPHINodes() {
while ((*PI)->getOpcode() == X86::PHI) ++PI;
MI->addRegOperand(getReg(PN->getIncomingValue(i), PredMBB, PI));
-
- // FIXME: Pass in the MachineBasicBlocks instead of the basic blocks...
- MI->addPCDispOperand(PN->getIncomingBlock(i)); // PredMBB
+ MI->addMachineBasicBlockOperand(PredMBB);
}
}
}
@@ -878,7 +884,7 @@ ISel::visitCastInst (CastInst &CI)
// 2) Implement casts between values of the same type class (as determined
// by getClass) by using a register-to-register move.
- unsigned srcClass = sourceType == Type::BoolTy ? cByte : getClass(sourceType);
+ unsigned srcClass = getClassB(sourceType);
unsigned targClass = getClass (targetType);
static const unsigned regRegMove[] = {
X86::MOVrr8, X86::MOVrr16, X86::MOVrr32
diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp
index 4a44dbf419..c436156561 100644
--- a/lib/Target/X86/X86ISelSimple.cpp
+++ b/lib/Target/X86/X86ISelSimple.cpp
@@ -273,6 +273,12 @@ static inline TypeClass getClass(const Type *Ty) {
}
}
+// getClassB - Just like getClass, but treat boolean values as bytes.
+static inline TypeClass getClassB(const Type *Ty) {
+ if (Ty == Type::BoolTy) return cByte;
+ return getClass(Ty);
+}
+
/// copyConstantToRegister - Output the instructions required to put the
/// specified constant into the specified register.
@@ -292,14 +298,16 @@ void ISel::copyConstantToRegister(Constant *C, unsigned R,
}
if (C->getType()->isIntegral()) {
- unsigned Class = getClass(C->getType());
+ unsigned Class = getClassB(C->getType());
assert(Class != 3 && "Type not handled yet!");
static const unsigned IntegralOpcodeTab[] = {
X86::MOVir8, X86::MOVir16, X86::MOVir32
};
- if (C->getType()->isSigned()) {
+ if (C->getType() == Type::BoolTy) {
+ BMI(MBB, IP, X86::MOVir8, 1, R).addZImm(C == ConstantBool::True);
+ } else if (C->getType()->isSigned()) {
ConstantSInt *CSI = cast<ConstantSInt>(C);
BMI(MBB, IP, IntegralOpcodeTab[Class], 1, R).addSImm(CSI->getValue());
} else {
@@ -348,9 +356,7 @@ void ISel::SelectPHINodes() {
while ((*PI)->getOpcode() == X86::PHI) ++PI;
MI->addRegOperand(getReg(PN->getIncomingValue(i), PredMBB, PI));
-
- // FIXME: Pass in the MachineBasicBlocks instead of the basic blocks...
- MI->addPCDispOperand(PN->getIncomingBlock(i)); // PredMBB
+ MI->addMachineBasicBlockOperand(PredMBB);
}
}
}
@@ -878,7 +884,7 @@ ISel::visitCastInst (CastInst &CI)
// 2) Implement casts between values of the same type class (as determined
// by getClass) by using a register-to-register move.
- unsigned srcClass = sourceType == Type::BoolTy ? cByte : getClass(sourceType);
+ unsigned srcClass = getClassB(sourceType);
unsigned targClass = getClass (targetType);
static const unsigned regRegMove[] = {
X86::MOVrr8, X86::MOVrr16, X86::MOVrr32