[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
Reid Spencer
reid at x10sys.com
Fri May 18 18:36:35 PDT 2007
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
ExternalFunctions.cpp updated: 1.98 -> 1.99
---
Log message:
On Linux platforms and at optimization levels -O1 and above, llvm-gcc can
turn "putchar" calls into _IO_putc calls which is a lower-level interface.
This patch allows these calls to be executed by lli in interpreter mode.
---
Diffs of the changes: (+14 -3)
ExternalFunctions.cpp | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
Index: llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.98 llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.99
--- llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.98 Sat Apr 21 12:11:45 2007
+++ llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Fri May 18 20:36:17 2007
@@ -72,13 +72,13 @@
ExFunc FnPtr = FuncNames[ExtName];
if (FnPtr == 0)
- FnPtr =
- (ExFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol(ExtName);
- if (FnPtr == 0)
FnPtr = FuncNames["lle_X_"+F->getName()];
if (FnPtr == 0) // Try calling a generic function... if it exists...
FnPtr = (ExFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol(
("lle_X_"+F->getName()).c_str());
+ if (FnPtr == 0)
+ FnPtr = (ExFunc)(intptr_t)
+ sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName());
if (FnPtr != 0)
Functions.insert(std::make_pair(F, FnPtr)); // Cache for later
return FnPtr;
@@ -118,6 +118,16 @@
return Args[0];
}
+// void _IO_putc(int c, FILE* fp)
+GenericValue lle_X__IO_putc(FunctionType *FT, const vector<GenericValue> &Args){
+#ifdef __linux__
+ _IO_putc((char)Args[0].IntVal.getZExtValue(), (FILE*) Args[1].PointerVal);
+#else
+ assert(0 && "Can't call _IO_putc on this platform");
+#endif
+ return Args[0];
+}
+
// void atexit(Function*)
GenericValue lle_X_atexit(FunctionType *FT, const vector<GenericValue> &Args) {
assert(Args.size() == 1);
@@ -694,6 +704,7 @@
void Interpreter::initializeExternalFunctions() {
FuncNames["lle_X_putchar"] = lle_X_putchar;
+ FuncNames["lle_X__IO_putc"] = lle_X__IO_putc;
FuncNames["lle_X_exit"] = lle_X_exit;
FuncNames["lle_X_abort"] = lle_X_abort;
FuncNames["lle_X_malloc"] = lle_X_malloc;
More information about the llvm-commits
mailing list