[llvm-commits] [llvm-gcc-4.2] r41223 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h
Duncan Sands
baldrick at free.fr
Tue Aug 21 09:06:40 PDT 2007
Author: baldrick
Date: Tue Aug 21 11:06:40 2007
New Revision: 41223
URL: http://llvm.org/viewvc/llvm-project?rev=41223&view=rev
Log:
Allow complex constants to be used as lvalues.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-internal.h
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=41223&r1=41222&r2=41223&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Aug 21 11:06:40 2007
@@ -1008,8 +1008,9 @@
case IMAGPART_EXPR: return EmitLV_XXXXPART_EXPR(exp, 1);
// Constants.
- case LABEL_DECL: return TreeConstantToLLVM::EmitLV_LABEL_DECL(exp);
- case STRING_CST: return LValue(TreeConstantToLLVM::EmitLV_STRING_CST(exp));
+ case LABEL_DECL: return TreeConstantToLLVM::EmitLV_LABEL_DECL(exp);
+ case COMPLEX_CST: return LValue(TreeConstantToLLVM::EmitLV_COMPLEX_CST(exp));
+ case STRING_CST: return LValue(TreeConstantToLLVM::EmitLV_STRING_CST(exp));
// Type Conversion.
case VIEW_CONVERT_EXPR: return EmitLV_VIEW_CONVERT_EXPR(exp);
@@ -5756,6 +5757,7 @@
case CONST_DECL:
case VAR_DECL: return EmitLV_Decl(exp);
case LABEL_DECL: return EmitLV_LABEL_DECL(exp);
+ case COMPLEX_CST: return EmitLV_COMPLEX_CST(exp);
case STRING_CST: return EmitLV_STRING_CST(exp);
case COMPONENT_REF: return EmitLV_COMPONENT_REF(exp);
case ARRAY_RANGE_REF:
@@ -5817,6 +5819,22 @@
return ConstantExpr::getIntToPtr(C, PointerType::get(Type::Int8Ty));
}
+Constant *TreeConstantToLLVM::EmitLV_COMPLEX_CST(tree exp) {
+ Constant *Init = TreeConstantToLLVM::ConvertCOMPLEX_CST(exp);
+
+ // Cache the constants to avoid making obvious duplicates that have to be
+ // folded by the optimizer.
+ static std::map<Constant*, GlobalVariable*> ComplexCSTCache;
+ GlobalVariable *&Slot = ComplexCSTCache[Init];
+ if (Slot) return Slot;
+
+ // Create a new complex global.
+ Slot = new GlobalVariable(Init->getType(), true,
+ GlobalVariable::InternalLinkage,
+ Init, ".cpx", TheModule);
+ return Slot;
+}
+
Constant *TreeConstantToLLVM::EmitLV_STRING_CST(tree exp) {
Constant *Init = TreeConstantToLLVM::ConvertSTRING_CST(exp);
Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=41223&r1=41222&r2=41223&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Tue Aug 21 11:06:40 2007
@@ -593,6 +593,7 @@
static Constant *EmitLV(tree_node *exp);
static Constant *EmitLV_Decl(tree_node *exp);
static Constant *EmitLV_LABEL_DECL(tree_node *exp);
+ static Constant *EmitLV_COMPLEX_CST(tree_node *exp);
static Constant *EmitLV_STRING_CST(tree_node *exp);
static Constant *EmitLV_COMPONENT_REF(tree_node *exp);
static Constant *EmitLV_ARRAY_REF(tree_node *exp);
More information about the llvm-commits
mailing list