[llvm-commits] [gcc-plugin] r83072 - in /gcc-plugin/trunk: llvm-convert.cpp llvm-internal.h
Duncan Sands
baldrick at free.fr
Tue Sep 29 09:50:17 PDT 2009
Author: baldrick
Date: Tue Sep 29 11:50:17 2009
New Revision: 83072
URL: http://llvm.org/viewvc/llvm-project?rev=83072&view=rev
Log:
Compare operands are always gimple registers or constants.
Modified:
gcc-plugin/trunk/llvm-convert.cpp
gcc-plugin/trunk/llvm-internal.h
Modified: gcc-plugin/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-convert.cpp?rev=83072&r1=83071&r2=83072&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-convert.cpp (original)
+++ gcc-plugin/trunk/llvm-convert.cpp Tue Sep 29 11:50:17 2009
@@ -1155,6 +1155,15 @@
return Result;
}
+/// EmitGimpleReg - Convert the specified gimple register or constant of
+/// register type to an LLVM value.
+Value *TreeToLLVM::EmitGimpleReg(tree_node *reg) {
+ assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!");
+ assert((is_gimple_reg(reg) || is_gimple_min_invariant(reg)) &&
+ "Expected a register or a constant!");
+ return Emit(reg, 0);
+}
+
/// EmitLV - Convert the specified l-value tree node to LLVM code, returning
/// the address of the result.
LValue TreeToLLVM::EmitLV(tree exp) {
@@ -3126,12 +3135,8 @@
/// EmitCompare - Compare LHS with RHS using the appropriate comparison code.
/// The result is an i1 boolean.
Value *TreeToLLVM::EmitCompare(tree lhs, tree rhs, tree_code code) {
- const Type *LHSTy = ConvertType(TREE_TYPE(lhs));
-
- assert((LHSTy == ConvertType(TREE_TYPE(rhs)) ||
- (isa<PointerType>(LHSTy) &&
- isa<PointerType>(ConvertType(TREE_TYPE(rhs))))) &&
- "Unexpected types for comparison");
+ Value *LHS = EmitGimpleReg(lhs);
+ Value *RHS = Builder.CreateBitCast(EmitGimpleReg(rhs), LHS->getType());
// Compute the LLVM opcodes corresponding to the GCC comparison.
CmpInst::Predicate UIPred = CmpInst::BAD_ICMP_PREDICATE;
@@ -3181,9 +3186,9 @@
if (TREE_CODE(TREE_TYPE(lhs)) == COMPLEX_TYPE) {
Value *LHSr, *LHSi;
- SplitComplex(Emit(lhs, 0), LHSr, LHSi);
+ SplitComplex(LHS, LHSr, LHSi);
Value *RHSr, *RHSi;
- SplitComplex(Emit(rhs, 0), RHSr, RHSi);
+ SplitComplex(RHS, RHSr, RHSi);
Value *DSTr, *DSTi;
if (LHSr->getType()->isFloatingPoint()) {
@@ -3204,12 +3209,7 @@
return Builder.CreateOr(DSTr, DSTi);
}
- // Get the compare operands in the right type. Comparison of struct is not
- // allowed, so this is safe as we already handled complex (struct) type.
- Value *LHS = Emit(lhs, 0);
- Value *RHS = Builder.CreateBitCast(Emit(rhs, 0), LHSTy);
-
- if (LHSTy->isFloatingPoint())
+ if (LHS->getType()->isFPOrFPVector())
return Builder.CreateFCmp(FPPred, LHS, RHS);
// Determine which predicate to use based on signedness.
Modified: gcc-plugin/trunk/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-internal.h?rev=83072&r1=83071&r2=83072&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-internal.h (original)
+++ gcc-plugin/trunk/llvm-internal.h Tue Sep 29 11:50:17 2009
@@ -509,6 +509,10 @@
/// DestLoc.
Value *Emit(tree_node *exp, const MemRef *DestLoc);
+ /// EmitGimpleReg - Convert the specified gimple register or constant of
+ /// register type to an LLVM value.
+ Value *EmitGimpleReg(tree_node *reg);
+
/// EmitBlock - Add the specified basic block to the end of the function. If
/// the previous block falls through into it, add an explicit branch.
void EmitBlock(BasicBlock *BB);
More information about the llvm-commits
mailing list