[llvm-commits] CVS: llvm/tools/lli/JIT/Emitter.cpp JIT.cpp VM.h SparcEmitter.cpp
Misha Brukman
brukman at cs.uiuc.edu
Sun Jun 1 22:24:00 PDT 2003
Changes in directory llvm/tools/lli/JIT:
Emitter.cpp updated: 1.9 -> 1.10
JIT.cpp updated: 1.5 -> 1.6
VM.h updated: 1.7 -> 1.8
SparcEmitter.cpp (r1.7) removed
---
Log message:
* Removed SparcEmitter.cpp; rolled into lib/Target/Sparc/SparcV9CodeEmitter.cpp
* No more createX86Emitter() vs. createSparcEmitter() -- there can be only one
* As a result, the memory management semantics must be handled according to
platform -- the parameters to mmap() are particularly sensitive to the host
architecture.
---
Diffs of the changes:
Index: llvm/tools/lli/JIT/Emitter.cpp
diff -u llvm/tools/lli/JIT/Emitter.cpp:1.9 llvm/tools/lli/JIT/Emitter.cpp:1.10
--- llvm/tools/lli/JIT/Emitter.cpp:1.9 Sun Jun 1 19:09:00 2003
+++ llvm/tools/lli/JIT/Emitter.cpp Sun Jun 1 22:23:16 2003
@@ -55,7 +55,7 @@
};
}
-MachineCodeEmitter *VM::createX86Emitter(VM &V) {
+MachineCodeEmitter *VM::createEmitter(VM &V) {
return new Emitter(V);
}
@@ -67,8 +67,25 @@
// FIXME: This should be rewritten to support a real memory manager for
// executable memory pages!
static void *getMemory(unsigned NumPages) {
- return mmap(0, 4096*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+#if defined(i386) || defined(__i386__) || defined(__x86__)
+ static const int fd = 0;
+#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
+ static const int fd = -1;
+#else
+ // This is an unsupported architecture.
+ static const int fd = 0;
+#endif
+
+ void *pa;
+ if (NumPages == 0) return 0;
+ static const long pageSize = sysconf (_SC_PAGESIZE);
+ pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANONYMOUS, fd, 0);
+ if (pa == MAP_FAILED) {
+ perror("mmap");
+ abort();
+ }
+ return pa;
}
Index: llvm/tools/lli/JIT/JIT.cpp
diff -u llvm/tools/lli/JIT/JIT.cpp:1.5 llvm/tools/lli/JIT/JIT.cpp:1.6
--- llvm/tools/lli/JIT/JIT.cpp:1.5 Sun Jun 1 18:24:36 2003
+++ llvm/tools/lli/JIT/JIT.cpp Sun Jun 1 22:23:16 2003
@@ -43,7 +43,7 @@
if (Arch == "x86") {
TargetMachineAllocator = allocateX86TargetMachine;
} else if (Arch == "sparc") {
- //TargetMachineAllocator = allocateSparcTargetMachine;
+ TargetMachineAllocator = allocateSparcTargetMachine;
}
if (TargetMachineAllocator) {
@@ -62,11 +62,7 @@
setTargetData(TM.getTargetData());
// Initialize MCE
- if (Arch == "x86") {
- MCE = createX86Emitter(*this);
- } else if (Arch == "sparc") {
- //MCE = createSparcEmitter(*this);
- }
+ MCE = createEmitter(*this);
setupPassManager();
emitGlobals();
Index: llvm/tools/lli/JIT/VM.h
diff -u llvm/tools/lli/JIT/VM.h:1.7 llvm/tools/lli/JIT/VM.h:1.8
--- llvm/tools/lli/JIT/VM.h:1.7 Sun Jun 1 18:24:36 2003
+++ llvm/tools/lli/JIT/VM.h Sun Jun 1 22:23:16 2003
@@ -52,8 +52,7 @@
void *getPointerToFunction(const Function *F);
private:
- static MachineCodeEmitter *createX86Emitter(VM &V);
- static MachineCodeEmitter *createSparcEmitter(VM &V);
+ static MachineCodeEmitter *createEmitter(VM &V);
void setupPassManager();
};
More information about the llvm-commits
mailing list