[llvm-commits] [dragonegg] r128076 - /dragonegg/trunk/Constants.cpp
Duncan Sands
baldrick at free.fr
Tue Mar 22 01:48:10 PDT 2011
Author: baldrick
Date: Tue Mar 22 03:48:10 2011
New Revision: 128076
URL: http://llvm.org/viewvc/llvm-project?rev=128076&view=rev
Log:
Unify handling of CONVERT_EXPR and NOP_EXPR.
Modified:
dragonegg/trunk/Constants.cpp
Modified: dragonegg/trunk/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=128076&r1=128075&r2=128076&view=diff
==============================================================================
--- dragonegg/trunk/Constants.cpp (original)
+++ dragonegg/trunk/Constants.cpp Tue Mar 22 03:48:10 2011
@@ -496,23 +496,13 @@
return AddressOf(TREE_OPERAND(exp, 0));
}
-static Constant *ConvertNOP_EXPR(tree exp) {
- Constant *Elt = ConvertInitializer(TREE_OPERAND(exp, 0));
- const Type *Ty = ConvertType(TREE_TYPE(exp));
- bool EltIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0)));
- bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
-
- // If this is a structure-to-structure cast, just return the uncasted value.
- if (!Elt->getType()->isSingleValueType() || !Ty->isSingleValueType())
- return Elt;
-
- // Elt and Ty can be integer, float or pointer here: need generalized cast
- Instruction::CastOps opcode = CastInst::getCastOpcode(Elt, EltIsSigned,
- Ty, TyIsSigned);
- return TheFolder->CreateCast(opcode, Elt, Ty);
-}
-
static Constant *ConvertCONVERT_EXPR(tree exp) {
+ if (AGGREGATE_TYPE_P(TREE_TYPE(exp)) ||
+ AGGREGATE_TYPE_P(TREE_TYPE(TREE_OPERAND(exp, 0)))) {
+ // A no-op record view conversion. These do not change any of the bits in
+ // the constant so just ignore them.
+ return ConvertInitializer(TREE_OPERAND(exp, 0));
+ }
Constant *Elt = ConvertInitializer(TREE_OPERAND(exp, 0));
bool EltIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0)));
const Type *Ty = ConvertType(TREE_TYPE(exp));
@@ -1221,10 +1211,8 @@
case STRING_CST:
Init = ConvertSTRING_CST(exp);
break;
- case NOP_EXPR:
- Init = ConvertNOP_EXPR(exp);
- break;
case CONVERT_EXPR:
+ case NOP_EXPR:
Init = ConvertCONVERT_EXPR(exp);
break;
case PLUS_EXPR:
More information about the llvm-commits
mailing list