[llvm-commits] [gcc-plugin] r79527 - /gcc-plugin/trunk/llvm-convert.cpp
Duncan Sands
baldrick at free.fr
Thu Aug 20 05:28:18 PDT 2009
Author: baldrick
Date: Thu Aug 20 07:28:18 2009
New Revision: 79527
URL: http://llvm.org/viewvc/llvm-project?rev=79527&view=rev
Log:
For the moment, convert gimple into trees rather than
trying to handle gimple directly.
Modified:
gcc-plugin/trunk/llvm-convert.cpp
Modified: gcc-plugin/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-convert.cpp?rev=79527&r1=79526&r2=79527&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-convert.cpp (original)
+++ gcc-plugin/trunk/llvm-convert.cpp Thu Aug 20 07:28:18 2009
@@ -747,6 +747,8 @@
return Fn;
}
+extern "C" tree gimple_to_tree(gimple);
+
Function *TreeToLLVM::EmitFunction() {
// Set up parameters and prepare for return, for the function.
StartFunctionBody();
@@ -758,9 +760,9 @@
FOR_EACH_BB (bb) {
for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
gsi_next (&gsi)) {
- gimple stmt = gsi_stmt (gsi);
+ gimple gimple_stmt = gsi_stmt (gsi);
- switch (gimple_code(stmt)) {
+ switch (gimple_code(gimple_stmt)) {
case GIMPLE_ASSIGN:
case GIMPLE_COND:
case GIMPLE_GOTO:
@@ -771,11 +773,25 @@
case GIMPLE_SWITCH:
case GIMPLE_NOP:
case GIMPLE_PREDICT:
- case GIMPLE_RESX:
+ case GIMPLE_RESX: {
+ // TODO Handle gimple directly, rather than converting to a tree.
+ MemRef DestLoc;
+ tree stmt = gimple_to_tree(gimple_stmt);
+
+ // If this stmt returns an aggregate value (e.g. a call whose result is
+ // ignored), create a temporary to receive the value. Note that we don't
+ // do this for MODIFY_EXPRs as an efficiency hack.
+ if (isAggregateTreeType(TREE_TYPE(stmt)) &&
+ TREE_CODE(stmt)!= MODIFY_EXPR && TREE_CODE(stmt)!=INIT_EXPR)
+ DestLoc = CreateTempLoc(ConvertType(TREE_TYPE(stmt)));
+
+ Emit(stmt, DestLoc.Ptr ? &DestLoc : NULL);
+ break;
+ }
+
default:
- print_gimple_stmt(stderr, stmt, 0, TDF_RAW);
+ print_gimple_stmt(stderr, gimple_stmt, 0, TDF_RAW);
llvm_report_error("Unhandled GIMPLE statement during LLVM emission!");
- break;
}
}
More information about the llvm-commits
mailing list