mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 15:17:25 +00:00
Twines: Don't allow implicit conversion from integers, this is too tricky.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77605 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -252,22 +252,22 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a twine to print \arg Val as an unsigned decimal integer.
|
/// Construct a twine to print \arg Val as an unsigned decimal integer.
|
||||||
Twine(const uint32_t &Val)
|
explicit Twine(const uint32_t &Val)
|
||||||
: LHS(&Val), LHSKind(UDec32Kind), RHSKind(EmptyKind) {
|
: LHS(&Val), LHSKind(UDec32Kind), RHSKind(EmptyKind) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a twine to print \arg Val as a signed decimal integer.
|
/// Construct a twine to print \arg Val as a signed decimal integer.
|
||||||
Twine(const int32_t &Val)
|
explicit Twine(const int32_t &Val)
|
||||||
: LHS(&Val), LHSKind(SDec32Kind), RHSKind(EmptyKind) {
|
: LHS(&Val), LHSKind(SDec32Kind), RHSKind(EmptyKind) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a twine to print \arg Val as an unsigned decimal integer.
|
/// Construct a twine to print \arg Val as an unsigned decimal integer.
|
||||||
Twine(const uint64_t &Val)
|
explicit Twine(const uint64_t &Val)
|
||||||
: LHS(&Val), LHSKind(UDec64Kind), RHSKind(EmptyKind) {
|
: LHS(&Val), LHSKind(UDec64Kind), RHSKind(EmptyKind) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a twine to print \arg Val as a signed decimal integer.
|
/// Construct a twine to print \arg Val as a signed decimal integer.
|
||||||
Twine(const int64_t &Val)
|
explicit Twine(const int64_t &Val)
|
||||||
: LHS(&Val), LHSKind(SDec64Kind), RHSKind(EmptyKind) {
|
: LHS(&Val), LHSKind(SDec64Kind), RHSKind(EmptyKind) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -764,9 +764,9 @@ Function *ArgPromotion::DoPromotion(Function *F,
|
|||||||
Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
|
Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
|
||||||
Value *Idx =
|
Value *Idx =
|
||||||
GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2,
|
GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2,
|
||||||
TheAlloca->getName()+"."+i,
|
TheAlloca->getName()+"."+Twine(i),
|
||||||
InsertPt);
|
InsertPt);
|
||||||
I2->setName(I->getName()+"."+i);
|
I2->setName(I->getName()+"."+Twine(i));
|
||||||
new StoreInst(I2++, Idx, InsertPt);
|
new StoreInst(I2++, Idx, InsertPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
|
|||||||
GlobalVariable *NGV = new GlobalVariable(Context,
|
GlobalVariable *NGV = new GlobalVariable(Context,
|
||||||
STy->getElementType(i), false,
|
STy->getElementType(i), false,
|
||||||
GlobalVariable::InternalLinkage,
|
GlobalVariable::InternalLinkage,
|
||||||
In, GV->getName()+"."+i,
|
In, GV->getName()+"."+Twine(i),
|
||||||
GV->isThreadLocal(),
|
GV->isThreadLocal(),
|
||||||
GV->getType()->getAddressSpace());
|
GV->getType()->getAddressSpace());
|
||||||
Globals.insert(GV, NGV);
|
Globals.insert(GV, NGV);
|
||||||
@@ -530,7 +530,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
|
|||||||
GlobalVariable *NGV = new GlobalVariable(Context,
|
GlobalVariable *NGV = new GlobalVariable(Context,
|
||||||
STy->getElementType(), false,
|
STy->getElementType(), false,
|
||||||
GlobalVariable::InternalLinkage,
|
GlobalVariable::InternalLinkage,
|
||||||
In, GV->getName()+"."+i,
|
In, GV->getName()+"."+Twine(i),
|
||||||
GV->isThreadLocal(),
|
GV->isThreadLocal(),
|
||||||
GV->getType()->getAddressSpace());
|
GV->getType()->getAddressSpace());
|
||||||
Globals.insert(GV, NGV);
|
Globals.insert(GV, NGV);
|
||||||
@@ -584,7 +584,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
|
|||||||
for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i)
|
for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i)
|
||||||
Idxs.push_back(GEPI->getOperand(i));
|
Idxs.push_back(GEPI->getOperand(i));
|
||||||
NewPtr = GetElementPtrInst::Create(NewPtr, Idxs.begin(), Idxs.end(),
|
NewPtr = GetElementPtrInst::Create(NewPtr, Idxs.begin(), Idxs.end(),
|
||||||
GEPI->getName()+"."+Val, GEPI);
|
GEPI->getName()+"."+Twine(Val),GEPI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GEP->replaceAllUsesWith(NewPtr);
|
GEP->replaceAllUsesWith(NewPtr);
|
||||||
@@ -1152,7 +1152,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo,
|
|||||||
Result = new LoadInst(GetHeapSROAValue(LI->getOperand(0), FieldNo,
|
Result = new LoadInst(GetHeapSROAValue(LI->getOperand(0), FieldNo,
|
||||||
InsertedScalarizedValues,
|
InsertedScalarizedValues,
|
||||||
PHIsToRewrite, Context),
|
PHIsToRewrite, Context),
|
||||||
LI->getName()+".f" + FieldNo, LI);
|
LI->getName()+".f"+Twine(FieldNo), LI);
|
||||||
} else if (PHINode *PN = dyn_cast<PHINode>(V)) {
|
} else if (PHINode *PN = dyn_cast<PHINode>(V)) {
|
||||||
// PN's type is pointer to struct. Make a new PHI of pointer to struct
|
// PN's type is pointer to struct. Make a new PHI of pointer to struct
|
||||||
// field.
|
// field.
|
||||||
@@ -1161,7 +1161,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo,
|
|||||||
|
|
||||||
Result =
|
Result =
|
||||||
PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
|
PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
|
||||||
PN->getName()+".f"+FieldNo, PN);
|
PN->getName()+".f"+Twine(FieldNo), PN);
|
||||||
PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
|
PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
|
||||||
} else {
|
} else {
|
||||||
llvm_unreachable("Unknown usable value");
|
llvm_unreachable("Unknown usable value");
|
||||||
@@ -1287,12 +1287,12 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
|
|||||||
new GlobalVariable(*GV->getParent(),
|
new GlobalVariable(*GV->getParent(),
|
||||||
PFieldTy, false, GlobalValue::InternalLinkage,
|
PFieldTy, false, GlobalValue::InternalLinkage,
|
||||||
Context.getNullValue(PFieldTy),
|
Context.getNullValue(PFieldTy),
|
||||||
GV->getName() + ".f" + FieldNo, GV,
|
GV->getName() + ".f" + Twine(FieldNo), GV,
|
||||||
GV->isThreadLocal());
|
GV->isThreadLocal());
|
||||||
FieldGlobals.push_back(NGV);
|
FieldGlobals.push_back(NGV);
|
||||||
|
|
||||||
MallocInst *NMI = new MallocInst(FieldTy, MI->getArraySize(),
|
MallocInst *NMI = new MallocInst(FieldTy, MI->getArraySize(),
|
||||||
MI->getName() + ".f" + FieldNo,MI);
|
MI->getName() + ".f" + Twine(FieldNo), MI);
|
||||||
FieldMallocs.push_back(NMI);
|
FieldMallocs.push_back(NMI);
|
||||||
new StoreInst(NMI, NGV, MI);
|
new StoreInst(NMI, NGV, MI);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ void SROA::DoScalarReplacement(AllocationInst *AI,
|
|||||||
for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) {
|
for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) {
|
||||||
AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0,
|
AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0,
|
||||||
AI->getAlignment(),
|
AI->getAlignment(),
|
||||||
AI->getName() + "." + i, AI);
|
AI->getName() + "." + Twine(i), AI);
|
||||||
ElementAllocas.push_back(NA);
|
ElementAllocas.push_back(NA);
|
||||||
WorkList.push_back(NA); // Add to worklist for recursive processing
|
WorkList.push_back(NA); // Add to worklist for recursive processing
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ void SROA::DoScalarReplacement(AllocationInst *AI,
|
|||||||
const Type *ElTy = AT->getElementType();
|
const Type *ElTy = AT->getElementType();
|
||||||
for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) {
|
for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) {
|
||||||
AllocaInst *NA = new AllocaInst(ElTy, 0, AI->getAlignment(),
|
AllocaInst *NA = new AllocaInst(ElTy, 0, AI->getAlignment(),
|
||||||
AI->getName() + "." + i, AI);
|
AI->getName() + "." + Twine(i), AI);
|
||||||
ElementAllocas.push_back(NA);
|
ElementAllocas.push_back(NA);
|
||||||
WorkList.push_back(NA); // Add to worklist for recursive processing
|
WorkList.push_back(NA); // Add to worklist for recursive processing
|
||||||
}
|
}
|
||||||
@@ -776,7 +776,7 @@ void SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *BCInst,
|
|||||||
if (OtherPtr) {
|
if (OtherPtr) {
|
||||||
Value *Idx[2] = { Zero, ConstantInt::get(Type::Int32Ty, i) };
|
Value *Idx[2] = { Zero, ConstantInt::get(Type::Int32Ty, i) };
|
||||||
OtherElt = GetElementPtrInst::Create(OtherPtr, Idx, Idx + 2,
|
OtherElt = GetElementPtrInst::Create(OtherPtr, Idx, Idx + 2,
|
||||||
OtherPtr->getNameStr()+"."+i,
|
OtherPtr->getNameStr()+"."+Twine(i),
|
||||||
MI);
|
MI);
|
||||||
uint64_t EltOffset;
|
uint64_t EltOffset;
|
||||||
const PointerType *OtherPtrTy = cast<PointerType>(OtherPtr->getType());
|
const PointerType *OtherPtrTy = cast<PointerType>(OtherPtr->getType());
|
||||||
|
|||||||
@@ -867,7 +867,7 @@ bool PromoteMem2Reg::QueuePhiNode(BasicBlock *BB, unsigned AllocaNo,
|
|||||||
// Create a PhiNode using the dereferenced type... and add the phi-node to the
|
// Create a PhiNode using the dereferenced type... and add the phi-node to the
|
||||||
// BasicBlock.
|
// BasicBlock.
|
||||||
PN = PHINode::Create(Allocas[AllocaNo]->getAllocatedType(),
|
PN = PHINode::Create(Allocas[AllocaNo]->getAllocatedType(),
|
||||||
Allocas[AllocaNo]->getName() + "." + Version++,
|
Allocas[AllocaNo]->getName() + "." + Twine(Version++),
|
||||||
BB->begin());
|
BB->begin());
|
||||||
++NumPHIInsert;
|
++NumPHIInsert;
|
||||||
PhiToAllocaMap[PN] = AllocaNo;
|
PhiToAllocaMap[PN] = AllocaNo;
|
||||||
|
|||||||
@@ -17,6 +17,32 @@
|
|||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
static std::string FlattenVariants(const std::string &AsmString,
|
||||||
|
unsigned Index) {
|
||||||
|
StringRef Cur = AsmString;
|
||||||
|
std::string Res = "";
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
std::pair<StringRef, StringRef> Split = Cur.split('{');
|
||||||
|
|
||||||
|
Res += Split.first;
|
||||||
|
if (Split.second.empty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
std::pair<StringRef, StringRef> Inner = Cur.split('}');
|
||||||
|
StringRef Selection = Inner.first;
|
||||||
|
for (unsigned i = 0; i != Index; ++i)
|
||||||
|
Selection = Selection.split('|').second;
|
||||||
|
Selection = Selection.split('|').first;
|
||||||
|
|
||||||
|
Res += Selection;
|
||||||
|
|
||||||
|
Cur = Inner.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Res;
|
||||||
|
}
|
||||||
|
|
||||||
void AsmMatcherEmitter::run(raw_ostream &OS) {
|
void AsmMatcherEmitter::run(raw_ostream &OS) {
|
||||||
CodeGenTarget Target;
|
CodeGenTarget Target;
|
||||||
const std::vector<CodeGenRegister> &Registers = Target.getRegisters();
|
const std::vector<CodeGenRegister> &Registers = Target.getRegisters();
|
||||||
@@ -44,4 +70,29 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
|
|||||||
}
|
}
|
||||||
OS << " return true;\n";
|
OS << " return true;\n";
|
||||||
OS << "}\n";
|
OS << "}\n";
|
||||||
|
|
||||||
|
// Emit the function to match instructions.
|
||||||
|
std::vector<const CodeGenInstruction*> NumberedInstructions;
|
||||||
|
Target.getInstructionsByEnumValue(NumberedInstructions);
|
||||||
|
|
||||||
|
const std::map<std::string, CodeGenInstruction> &Instructions =
|
||||||
|
Target.getInstructions();
|
||||||
|
for (std::map<std::string, CodeGenInstruction>::const_iterator
|
||||||
|
it = Instructions.begin(), ie = Instructions.end(); it != ie; ++it) {
|
||||||
|
const CodeGenInstruction &CGI = it->second;
|
||||||
|
|
||||||
|
if (it->first != "SUB8rr")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
|
||||||
|
"sub{b}\t{$src2, $dst|$dst, $src2}",
|
||||||
|
[(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
|
||||||
|
(implicit EFLAGS)]>;
|
||||||
|
*/
|
||||||
|
|
||||||
|
outs() << it->first << " "
|
||||||
|
<< FlattenVariants(CGI.AsmString, 0)
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user