mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-07 14:33:15 +00:00
StringRefize and simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144675 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6c5b2dcd83
commit
b5ccb25bc2
@ -68,7 +68,7 @@ namespace llvm {
|
|||||||
/// 'Op' and returns one value with the same type. If 'Op' is a long double,
|
/// 'Op' and returns one value with the same type. If 'Op' is a long double,
|
||||||
/// 'l' is added as the suffix of name, if 'Op' is a float, we add a 'f'
|
/// 'l' is added as the suffix of name, if 'Op' is a float, we add a 'f'
|
||||||
/// suffix.
|
/// suffix.
|
||||||
Value *EmitUnaryFloatFnCall(Value *Op, const char *Name, IRBuilder<> &B,
|
Value *EmitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B,
|
||||||
const AttrListPtr &Attrs);
|
const AttrListPtr &Attrs);
|
||||||
|
|
||||||
/// EmitPutChar - Emit a call to the putchar function. This assumes that Char
|
/// EmitPutChar - Emit a call to the putchar function. This assumes that Char
|
||||||
|
@ -963,8 +963,7 @@ struct UnaryDoubleFPOpt : public LibCallOptimization {
|
|||||||
|
|
||||||
// floor((double)floatval) -> (double)floorf(floatval)
|
// floor((double)floatval) -> (double)floorf(floatval)
|
||||||
Value *V = Cast->getOperand(0);
|
Value *V = Cast->getOperand(0);
|
||||||
V = EmitUnaryFloatFnCall(V, Callee->getName().data(), B,
|
V = EmitUnaryFloatFnCall(V, Callee->getName(), B, Callee->getAttributes());
|
||||||
Callee->getAttributes());
|
|
||||||
return B.CreateFPExt(V, B.getDoubleTy());
|
return B.CreateFPExt(V, B.getDoubleTy());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
|
#include "llvm/Intrinsics.h"
|
||||||
|
#include "llvm/LLVMContext.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Support/IRBuilder.h"
|
#include "llvm/Support/IRBuilder.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/LLVMContext.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/Intrinsics.h"
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -206,19 +207,16 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
|
|||||||
/// 'floor'). This function is known to take a single of type matching 'Op' and
|
/// 'floor'). This function is known to take a single of type matching 'Op' and
|
||||||
/// returns one value with the same type. If 'Op' is a long double, 'l' is
|
/// returns one value with the same type. If 'Op' is a long double, 'l' is
|
||||||
/// added as the suffix of name, if 'Op' is a float, we add a 'f' suffix.
|
/// added as the suffix of name, if 'Op' is a float, we add a 'f' suffix.
|
||||||
Value *llvm::EmitUnaryFloatFnCall(Value *Op, const char *Name,
|
Value *llvm::EmitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B,
|
||||||
IRBuilder<> &B, const AttrListPtr &Attrs) {
|
const AttrListPtr &Attrs) {
|
||||||
char NameBuffer[20];
|
SmallString<20> NameBuffer;
|
||||||
if (!Op->getType()->isDoubleTy()) {
|
if (!Op->getType()->isDoubleTy()) {
|
||||||
// If we need to add a suffix, copy into NameBuffer.
|
// If we need to add a suffix, copy into NameBuffer.
|
||||||
unsigned NameLen = strlen(Name);
|
NameBuffer += Name;
|
||||||
assert(NameLen < sizeof(NameBuffer)-2);
|
|
||||||
memcpy(NameBuffer, Name, NameLen);
|
|
||||||
if (Op->getType()->isFloatTy())
|
if (Op->getType()->isFloatTy())
|
||||||
NameBuffer[NameLen] = 'f'; // floorf
|
NameBuffer += 'f'; // floorf
|
||||||
else
|
else
|
||||||
NameBuffer[NameLen] = 'l'; // floorl
|
NameBuffer += 'l'; // floorl
|
||||||
NameBuffer[NameLen+1] = 0;
|
|
||||||
Name = NameBuffer;
|
Name = NameBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user