summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2004-07-07 15:36:18 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2004-07-07 15:36:18 +0000
commitef84814ea94185d586045a3684c462afdc527342 (patch)
treec822caa8d528676f3ef0c930014ac54b49b0f975 /llvm
parent18a7abbc7539c50ac90e7a6773562de76d589b7a (diff)
downloadbcm5719-llvm-ef84814ea94185d586045a3684c462afdc527342.tar.gz
bcm5719-llvm-ef84814ea94185d586045a3684c462afdc527342.zip
Add fmod() to the Module being compiled so that it gets a stub in the asm file
llvm-svn: 14670
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp11
-rw-r--r--llvm/lib/Target/PowerPC/PowerPCISelSimple.cpp11
2 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp b/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
index b69f5c6f6d4..edcfccbb3b7 100644
--- a/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
+++ b/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
@@ -72,6 +72,7 @@ namespace {
struct ISel : public FunctionPass, InstVisitor<ISel> {
TargetMachine &TM;
MachineFunction *F; // The function we are compiling into
+ Module *M; // Current module
MachineBasicBlock *BB; // The current MBB we are compiling
int VarArgsFrameIndex; // FrameIndex for start of varargs area
int ReturnAddressIndex; // FrameIndex for the return address
@@ -87,10 +88,12 @@ namespace {
ISel(TargetMachine &tm) : TM(tm), F(0), BB(0) {}
- bool doInitialization(Module &M) {
+ bool doInitialization(Module &Mod) {
+ M = &Mod;
+ // Add external functions that we may call
Type *d = Type::DoubleTy;
// double fmod(double, double);
- // M.getOrInsertFunction("fmod", d, d, d, 0);
+ Mod.getOrInsertFunction("fmod", d, d, d, 0);
// { "__moddi3", "__divdi3", "__umoddi3", "__udivdi3" };
return false;
}
@@ -1946,8 +1949,10 @@ void ISel::emitDivRemOperation(MachineBasicBlock *BB,
} else { // Floating point remainder...
unsigned Op0Reg = getReg(Op0, BB, IP);
unsigned Op1Reg = getReg(Op1, BB, IP);
+ Function *FmodFn = M->getNamedFunction("fmod");
+ assert(FmodFn && "fmod() does not exist in the module");
MachineInstr *TheCall =
- BuildMI(PPC32::CALLpcrel, 1).addExternalSymbol("fmod", true);
+ BuildMI(PPC32::CALLpcrel, 1).addGlobalAddress(FmodFn, true);
std::vector<ValueRecord> Args;
Args.push_back(ValueRecord(Op0Reg, Type::DoubleTy));
Args.push_back(ValueRecord(Op1Reg, Type::DoubleTy));
diff --git a/llvm/lib/Target/PowerPC/PowerPCISelSimple.cpp b/llvm/lib/Target/PowerPC/PowerPCISelSimple.cpp
index b69f5c6f6d4..edcfccbb3b7 100644
--- a/llvm/lib/Target/PowerPC/PowerPCISelSimple.cpp
+++ b/llvm/lib/Target/PowerPC/PowerPCISelSimple.cpp
@@ -72,6 +72,7 @@ namespace {
struct ISel : public FunctionPass, InstVisitor<ISel> {
TargetMachine &TM;
MachineFunction *F; // The function we are compiling into
+ Module *M; // Current module
MachineBasicBlock *BB; // The current MBB we are compiling
int VarArgsFrameIndex; // FrameIndex for start of varargs area
int ReturnAddressIndex; // FrameIndex for the return address
@@ -87,10 +88,12 @@ namespace {
ISel(TargetMachine &tm) : TM(tm), F(0), BB(0) {}
- bool doInitialization(Module &M) {
+ bool doInitialization(Module &Mod) {
+ M = &Mod;
+ // Add external functions that we may call
Type *d = Type::DoubleTy;
// double fmod(double, double);
- // M.getOrInsertFunction("fmod", d, d, d, 0);
+ Mod.getOrInsertFunction("fmod", d, d, d, 0);
// { "__moddi3", "__divdi3", "__umoddi3", "__udivdi3" };
return false;
}
@@ -1946,8 +1949,10 @@ void ISel::emitDivRemOperation(MachineBasicBlock *BB,
} else { // Floating point remainder...
unsigned Op0Reg = getReg(Op0, BB, IP);
unsigned Op1Reg = getReg(Op1, BB, IP);
+ Function *FmodFn = M->getNamedFunction("fmod");
+ assert(FmodFn && "fmod() does not exist in the module");
MachineInstr *TheCall =
- BuildMI(PPC32::CALLpcrel, 1).addExternalSymbol("fmod", true);
+ BuildMI(PPC32::CALLpcrel, 1).addGlobalAddress(FmodFn, true);
std::vector<ValueRecord> Args;
Args.push_back(ValueRecord(Op0Reg, Type::DoubleTy));
Args.push_back(ValueRecord(Op1Reg, Type::DoubleTy));
OpenPOWER on IntegriCloud