Skip to content

Commit 2e7416c

Browse files
committed
Implement the TargetMachine::getJITStubForFunction method for X86, finegrainify
namespacification. llvm-svn: 10430
1 parent 538dffd commit 2e7416c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

llvm/lib/Target/X86/X86CodeEmitter.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
#include "Support/Debug.h"
2424
#include "Support/Statistic.h"
2525
#include "Config/alloca.h"
26-
27-
namespace llvm {
26+
using namespace llvm;
2827

2928
namespace {
3029
Statistic<>
@@ -54,6 +53,12 @@ namespace {
5453
JITResolver *TheJITResolver;
5554
}
5655

56+
void *X86TargetMachine::getJITStubForFunction(Function *F,
57+
MachineCodeEmitter &MCE) {
58+
if (TheJITResolver == 0)
59+
TheJITResolver = new JITResolver(MCE);
60+
return (void*)TheJITResolver->getLazyResolver(F);
61+
}
5762

5863
/// addFunctionReference - This method is called when we need to emit the
5964
/// address of a function that has not yet been emitted, so we don't know the
@@ -591,5 +596,3 @@ void Emitter::emitInstruction(MachineInstr &MI) {
591596
break;
592597
}
593598
}
594-
595-
} // End llvm namespace

llvm/lib/Target/X86/X86TargetMachine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class X86TargetMachine : public TargetMachine {
5555
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
5656

5757
virtual void replaceMachineCodeForFunction (void *Old, void *New);
58+
59+
/// getJITStubForFunction - Create or return a stub for the specified
60+
/// function. This stub acts just like the specified function, except that it
61+
/// allows the "address" of the function to be taken without having to
62+
/// generate code for it.
63+
virtual void *getJITStubForFunction(Function *F, MachineCodeEmitter &MCE);
5864
};
5965

6066
} // End llvm namespace

0 commit comments

Comments
 (0)