mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-20 09:24:58 +00:00
Switch UnaryOperators to default to passing names up by const char* when possible.
This speeds up bcreading by 1.5%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34233 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ec79b3da13
commit
f00042a999
@ -91,11 +91,11 @@ class UnaryInstruction : public Instruction {
|
|||||||
Use Op;
|
Use Op;
|
||||||
protected:
|
protected:
|
||||||
UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
|
UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
|
||||||
const std::string &Name = "", Instruction *IB = 0)
|
const char *Name = 0, Instruction *IB = 0)
|
||||||
: Instruction(Ty, iType, &Op, 1, Name, IB), Op(V, this) {
|
: Instruction(Ty, iType, &Op, 1, Name, IB), Op(V, this) {
|
||||||
}
|
}
|
||||||
UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
|
UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
|
||||||
const std::string &Name, BasicBlock *IAE)
|
const char *Name = 0, BasicBlock *IAE)
|
||||||
: Instruction(Ty, iType, &Op, 1, Name, IAE), Op(V, this) {
|
: Instruction(Ty, iType, &Op, 1, Name, IAE), Op(V, this) {
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
@ -263,13 +263,15 @@ class CastInst : public UnaryInstruction {
|
|||||||
protected:
|
protected:
|
||||||
/// @brief Constructor with insert-before-instruction semantics for subclasses
|
/// @brief Constructor with insert-before-instruction semantics for subclasses
|
||||||
CastInst(const Type *Ty, unsigned iType, Value *S,
|
CastInst(const Type *Ty, unsigned iType, Value *S,
|
||||||
const std::string &Name = "", Instruction *InsertBefore = 0)
|
const std::string &Name = "", Instruction *InsertBefore = 0)
|
||||||
: UnaryInstruction(Ty, iType, S, Name, InsertBefore) {
|
: UnaryInstruction(Ty, iType, S, 0, InsertBefore) {
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
/// @brief Constructor with insert-at-end-of-block semantics for subclasses
|
/// @brief Constructor with insert-at-end-of-block semantics for subclasses
|
||||||
CastInst(const Type *Ty, unsigned iType, Value *S,
|
CastInst(const Type *Ty, unsigned iType, Value *S,
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(Ty, iType, S, Name, InsertAtEnd) {
|
: UnaryInstruction(Ty, iType, S, 0, InsertAtEnd) {
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
/// Provides a way to construct any of the CastInst subclasses using an
|
/// Provides a way to construct any of the CastInst subclasses using an
|
||||||
|
@ -41,10 +41,13 @@ class Instruction : public User {
|
|||||||
void setParent(BasicBlock *P);
|
void setParent(BasicBlock *P);
|
||||||
protected:
|
protected:
|
||||||
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||||
const std::string &Name = "",
|
const std::string &Name, Instruction *InsertBefore = 0);
|
||||||
Instruction *InsertBefore = 0);
|
|
||||||
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd);
|
const std::string &Name, BasicBlock *InsertAtEnd);
|
||||||
|
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||||
|
const char *Name = 0, Instruction *InsertBefore = 0);
|
||||||
|
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||||
|
const char *Name, BasicBlock *InsertAtEnd);
|
||||||
public:
|
public:
|
||||||
// Out of line virtual method, so the vtable, etc has a home.
|
// Out of line virtual method, so the vtable, etc has a home.
|
||||||
~Instruction();
|
~Instruction();
|
||||||
|
@ -222,11 +222,18 @@ class LoadInst : public UnaryInstruction {
|
|||||||
public:
|
public:
|
||||||
LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
|
LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
|
||||||
LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
|
LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
|
||||||
explicit LoadInst(Value *Ptr, const std::string &Name = "",
|
LoadInst(Value *Ptr, const std::string &Name, bool isVolatile = false,
|
||||||
bool isVolatile = false, Instruction *InsertBefore = 0);
|
Instruction *InsertBefore = 0);
|
||||||
LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
||||||
BasicBlock *InsertAtEnd);
|
BasicBlock *InsertAtEnd);
|
||||||
|
|
||||||
|
LoadInst(Value *Ptr, const char *Name, Instruction *InsertBefore);
|
||||||
|
LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAtEnd);
|
||||||
|
explicit LoadInst(Value *Ptr, const char *Name = 0, bool isVolatile = false,
|
||||||
|
Instruction *InsertBefore = 0);
|
||||||
|
LoadInst(Value *Ptr, const char *Name, bool isVolatile,
|
||||||
|
BasicBlock *InsertAtEnd);
|
||||||
|
|
||||||
/// isVolatile - Return true if this is a load from a volatile memory
|
/// isVolatile - Return true if this is a load from a volatile memory
|
||||||
/// location.
|
/// location.
|
||||||
///
|
///
|
||||||
@ -828,11 +835,13 @@ class VAArgInst : public UnaryInstruction {
|
|||||||
public:
|
public:
|
||||||
VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
|
VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
|
||||||
Instruction *InsertBefore = 0)
|
Instruction *InsertBefore = 0)
|
||||||
: UnaryInstruction(Ty, VAArg, List, Name, InsertBefore) {
|
: UnaryInstruction(Ty, VAArg, List, 0, InsertBefore) {
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
VAArgInst(Value *List, const Type *Ty, const std::string &Name,
|
VAArgInst(Value *List, const Type *Ty, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(Ty, VAArg, List, Name, InsertAtEnd) {
|
: UnaryInstruction(Ty, VAArg, List, 0, InsertAtEnd) {
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual VAArgInst *clone() const;
|
virtual VAArgInst *clone() const;
|
||||||
|
@ -44,6 +44,34 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
|||||||
setName(Name);
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
||||||
|
const char *Name, Instruction *InsertBefore)
|
||||||
|
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
|
||||||
|
// Make sure that we get added to a basicblock
|
||||||
|
LeakDetector::addGarbageObject(this);
|
||||||
|
|
||||||
|
// If requested, insert this instruction into a basic block...
|
||||||
|
if (InsertBefore) {
|
||||||
|
assert(InsertBefore->getParent() &&
|
||||||
|
"Instruction to insert before is not in a basic block!");
|
||||||
|
InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
|
||||||
|
}
|
||||||
|
if (Name && *Name) setName(Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
||||||
|
const char *Name, BasicBlock *InsertAtEnd)
|
||||||
|
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
|
||||||
|
// Make sure that we get added to a basicblock
|
||||||
|
LeakDetector::addGarbageObject(this);
|
||||||
|
|
||||||
|
// append this instruction into the basic block
|
||||||
|
assert(InsertAtEnd && "Basic block to append to may not be NULL!");
|
||||||
|
InsertAtEnd->getInstList().push_back(this);
|
||||||
|
if (Name && *Name) setName(Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Out of line virtual method, so the vtable, etc has a home.
|
// Out of line virtual method, so the vtable, etc has a home.
|
||||||
Instruction::~Instruction() {
|
Instruction::~Instruction() {
|
||||||
assert(Parent == 0 && "Instruction still linked in the program!");
|
assert(Parent == 0 && "Instruction still linked in the program!");
|
||||||
|
@ -531,18 +531,20 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
|||||||
unsigned Align, const std::string &Name,
|
unsigned Align, const std::string &Name,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
||||||
Name, InsertBefore), Alignment(Align) {
|
0, InsertBefore), Alignment(Align) {
|
||||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||||
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
||||||
unsigned Align, const std::string &Name,
|
unsigned Align, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
||||||
Name, InsertAtEnd), Alignment(Align) {
|
0, InsertAtEnd), Alignment(Align) {
|
||||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||||
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Out of line virtual method, so the vtable, etc has a home.
|
// Out of line virtual method, so the vtable, etc has a home.
|
||||||
@ -579,12 +581,12 @@ void FreeInst::AssertOK() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore)
|
FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore)
|
||||||
: UnaryInstruction(Type::VoidTy, Free, Ptr, "", InsertBefore) {
|
: UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertBefore) {
|
||||||
AssertOK();
|
AssertOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd)
|
FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(Type::VoidTy, Free, Ptr, "", InsertAtEnd) {
|
: UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertAtEnd) {
|
||||||
AssertOK();
|
AssertOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,30 +602,66 @@ void LoadInst::AssertOK() {
|
|||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
|
LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, Name, InsertBef) {
|
Load, Ptr, 0, InsertBef) {
|
||||||
setVolatile(false);
|
setVolatile(false);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
|
LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, Name, InsertAE) {
|
Load, Ptr, 0, InsertAE) {
|
||||||
setVolatile(false);
|
setVolatile(false);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
||||||
Instruction *InsertBef)
|
Instruction *InsertBef)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, Name, InsertBef) {
|
Load, Ptr, 0, InsertBef) {
|
||||||
setVolatile(isVolatile);
|
setVolatile(isVolatile);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
||||||
BasicBlock *InsertAE)
|
BasicBlock *InsertAE)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, Name, InsertAE) {
|
Load, Ptr, 0, InsertAE) {
|
||||||
|
setVolatile(isVolatile);
|
||||||
|
AssertOK();
|
||||||
|
setName(Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LoadInst::LoadInst(Value *Ptr, const char *Name, Instruction *InsertBef)
|
||||||
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
|
Load, Ptr, Name, InsertBef) {
|
||||||
|
setVolatile(false);
|
||||||
|
AssertOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadInst::LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAE)
|
||||||
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
|
Load, Ptr, Name, InsertAE) {
|
||||||
|
setVolatile(false);
|
||||||
|
AssertOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
|
||||||
|
Instruction *InsertBef)
|
||||||
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
|
Load, Ptr, Name, InsertBef) {
|
||||||
|
setVolatile(isVolatile);
|
||||||
|
AssertOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
|
||||||
|
BasicBlock *InsertAE)
|
||||||
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
|
Load, Ptr, Name, InsertAE) {
|
||||||
setVolatile(isVolatile);
|
setVolatile(isVolatile);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user