--- /dev/null
+; RUN: llvm-as < %s | llc -fast-isel -march=x86
+
+define i8 @t2(i8 %a, i8 %c) nounwind {
+ %tmp = shl i8 %a, %c
+ ret i8 %tmp
+}
+
+define i8 @t1(i8 %a) nounwind {
+ %tmp = mul i8 %a, 17
+ ret i8 %tmp
+}
return false;
Record *OpLeafRec = OpDI->getDef();
// For now, the only other thing we accept is register operands.
return false;
Record *OpLeafRec = OpDI->getDef();
// For now, the only other thing we accept is register operands.
const CodeGenRegisterClass *RC = 0;
if (OpLeafRec->isSubClassOf("RegisterClass"))
RC = &Target.getRegisterClass(OpLeafRec);
const CodeGenRegisterClass *RC = 0;
if (OpLeafRec->isSubClassOf("RegisterClass"))
RC = &Target.getRegisterClass(OpLeafRec);
void PrintArguments(std::ostream &OS,
const std::vector<std::string>& PR) const {
assert(PR.size() == Operands.size());
void PrintArguments(std::ostream &OS,
const std::vector<std::string>& PR) const {
assert(PR.size() == Operands.size());
+ bool PrintedArg = false;
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
- if (PR[i] != "") {
- OS << PR[i];
- } else if (Operands[i] == "r") {
+ if (PR[i] != "")
+ // Implicit physical register operand.
+ continue;
+
+ if (PrintedArg)
+ OS << ", ";
+ if (Operands[i] == "r") {
} else if (Operands[i] == "i") {
OS << "imm" << i;
} else if (Operands[i] == "i") {
OS << "imm" << i;
} else if (Operands[i] == "f") {
OS << "f" << i;
} else if (Operands[i] == "f") {
OS << "f" << i;
} else {
assert("Unknown operand kind!");
abort();
}
} else {
assert("Unknown operand kind!");
abort();
}
- if (i + 1 != e)
- OS << ", ";
+ void PrintManglingSuffix(std::ostream &OS,
+ const std::vector<std::string>& PR) const {
+ for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
+ if (PR[i] != "")
+ // Implicit physical register operand. e.g. Instruction::Mul expect to
+ // select to a binary op. On x86, mul may take a single operand with
+ // the other operand being implicit. We must emit something that looks
+ // like a binary instruction except for the very inner FastEmitInst_*
+ // call.
+ continue;
+ OS << Operands[i];
+ }
+ }
+
void PrintManglingSuffix(std::ostream &OS) const {
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
OS << Operands[i];
void PrintManglingSuffix(std::ostream &OS) const {
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
OS << Operands[i];
OS << " return FastEmitInst_";
if (Memo.SubRegNo == (unsigned char)~0) {
OS << " return FastEmitInst_";
if (Memo.SubRegNo == (unsigned char)~0) {
- Operands.PrintManglingSuffix(OS);
+ Operands.PrintManglingSuffix(OS, *Memo.PhysRegs);
OS << "(" << InstNS << Memo.Name << ", ";
OS << InstNS << Memo.RC->getName() << "RegisterClass";
if (!Operands.empty())
OS << "(" << InstNS << Memo.Name << ", ";
OS << InstNS << Memo.RC->getName() << "RegisterClass";
if (!Operands.empty())
// Emit code for each possible instruction. There may be
// multiple if there are subtarget concerns.
// Emit code for each possible instruction. There may be
// multiple if there are subtarget concerns.
- for (PredMap::const_iterator PI = PM.begin(), PE = PM.end(); PI != PE; ++PI) {
+ for (PredMap::const_iterator PI = PM.begin(), PE = PM.end(); PI != PE;
+ ++PI) {
std::string PredicateCheck = PI->first;
const InstructionMemo &Memo = PI->second;
std::string PredicateCheck = PI->first;
const InstructionMemo &Memo = PI->second;
OS << " return FastEmitInst_";
if (Memo.SubRegNo == (unsigned char)~0) {
OS << " return FastEmitInst_";
if (Memo.SubRegNo == (unsigned char)~0) {
- Operands.PrintManglingSuffix(OS);
+ Operands.PrintManglingSuffix(OS, *Memo.PhysRegs);
OS << "(" << InstNS << Memo.Name << ", ";
OS << InstNS << Memo.RC->getName() << "RegisterClass";
if (!Operands.empty())
OS << "(" << InstNS << Memo.Name << ", ";
OS << InstNS << Memo.RC->getName() << "RegisterClass";
if (!Operands.empty())