mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Implemented x86 inline asm b, h, w, k modifiers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28020 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
94046b4d10
commit
62f2700bcf
@ -264,6 +264,124 @@ void X86ATTAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
|
||||
O << "\"L" << getFunctionNumber() << "$pb\":";
|
||||
}
|
||||
|
||||
|
||||
bool X86ATTAsmPrinter::printAsmMRegsiter(const MachineOperand &MO,
|
||||
const char Mode) {
|
||||
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
||||
unsigned Reg = MO.getReg();
|
||||
const char *Name = RI.get(Reg).Name;
|
||||
switch (Mode) {
|
||||
default: return true; // Unknown mode.
|
||||
case 'b': // Print QImode register
|
||||
switch (Reg) {
|
||||
default: return true;
|
||||
case X86::AH: case X86::AL: case X86::AX: case X86::EAX:
|
||||
Name = "al";
|
||||
break;
|
||||
case X86::DH: case X86::DL: case X86::DX: case X86::EDX:
|
||||
Name = "dl";
|
||||
break;
|
||||
case X86::CH: case X86::CL: case X86::CX: case X86::ECX:
|
||||
Name = "cl";
|
||||
break;
|
||||
case X86::BH: case X86::BL: case X86::BX: case X86::EBX:
|
||||
Name = "bl";
|
||||
break;
|
||||
case X86::ESI:
|
||||
Name = "sil";
|
||||
break;
|
||||
case X86::EDI:
|
||||
Name = "dil";
|
||||
break;
|
||||
case X86::EBP:
|
||||
Name = "bpl";
|
||||
break;
|
||||
case X86::ESP:
|
||||
Name = "spl";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'h': // Print QImode high register
|
||||
switch (Reg) {
|
||||
default: return true;
|
||||
case X86::AH: case X86::AL: case X86::AX: case X86::EAX:
|
||||
Name = "al";
|
||||
break;
|
||||
case X86::DH: case X86::DL: case X86::DX: case X86::EDX:
|
||||
Name = "dl";
|
||||
break;
|
||||
case X86::CH: case X86::CL: case X86::CX: case X86::ECX:
|
||||
Name = "cl";
|
||||
break;
|
||||
case X86::BH: case X86::BL: case X86::BX: case X86::EBX:
|
||||
Name = "bl";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'w': // Print HImode register
|
||||
switch (Reg) {
|
||||
default: return true;
|
||||
case X86::AH: case X86::AL: case X86::AX: case X86::EAX:
|
||||
Name = "ax";
|
||||
break;
|
||||
case X86::DH: case X86::DL: case X86::DX: case X86::EDX:
|
||||
Name = "dx";
|
||||
break;
|
||||
case X86::CH: case X86::CL: case X86::CX: case X86::ECX:
|
||||
Name = "cx";
|
||||
break;
|
||||
case X86::BH: case X86::BL: case X86::BX: case X86::EBX:
|
||||
Name = "bx";
|
||||
break;
|
||||
case X86::ESI:
|
||||
Name = "si";
|
||||
break;
|
||||
case X86::EDI:
|
||||
Name = "di";
|
||||
break;
|
||||
case X86::EBP:
|
||||
Name = "bp";
|
||||
break;
|
||||
case X86::ESP:
|
||||
Name = "sp";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'k': // Print SImode register
|
||||
switch (Reg) {
|
||||
default: return true;
|
||||
case X86::AH: case X86::AL: case X86::AX: case X86::EAX:
|
||||
Name = "eax";
|
||||
break;
|
||||
case X86::DH: case X86::DL: case X86::DX: case X86::EDX:
|
||||
Name = "edx";
|
||||
break;
|
||||
case X86::CH: case X86::CL: case X86::CX: case X86::ECX:
|
||||
Name = "ecx";
|
||||
break;
|
||||
case X86::BH: case X86::BL: case X86::BX: case X86::EBX:
|
||||
Name = "ebx";
|
||||
break;
|
||||
case X86::ESI:
|
||||
Name = "esi";
|
||||
break;
|
||||
case X86::EDI:
|
||||
Name = "edi";
|
||||
break;
|
||||
case X86::EBP:
|
||||
Name = "ebp";
|
||||
break;
|
||||
case X86::ESP:
|
||||
Name = "esp";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
O << '%' << Name;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// PrintAsmOperand - Print out an operand for an inline asm expression.
|
||||
///
|
||||
bool X86ATTAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
@ -275,6 +393,11 @@ bool X86ATTAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
|
||||
switch (ExtraCode[0]) {
|
||||
default: return true; // Unknown modifier.
|
||||
case 'b': // Print QImode register
|
||||
case 'h': // Print QImode high register
|
||||
case 'w': // Print HImode register
|
||||
case 'k': // Print SImode register
|
||||
return printAsmMRegsiter(MI->getOperand(OpNo), ExtraCode[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,11 +61,13 @@ struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
|
||||
printMemReference(MI, OpNo);
|
||||
}
|
||||
|
||||
bool printAsmMRegsiter(const MachineOperand &MO, const char Mode);
|
||||
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
unsigned AsmVariant, const char *ExtraCode);
|
||||
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
unsigned AsmVariant, const char *ExtraCode);
|
||||
void printMachineInstruction(const MachineInstr *MI);
|
||||
|
||||
void printMachineInstruction(const MachineInstr *MI);
|
||||
void printSSECC(const MachineInstr *MI, unsigned Op);
|
||||
void printMemReference(const MachineInstr *MI, unsigned Op);
|
||||
void printPICLabel(const MachineInstr *MI, unsigned Op);
|
||||
|
@ -242,6 +242,123 @@ void X86IntelAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
|
||||
O << "\"L" << getFunctionNumber() << "$pb\":";
|
||||
}
|
||||
|
||||
bool X86IntelAsmPrinter::printAsmMRegsiter(const MachineOperand &MO,
|
||||
const char Mode) {
|
||||
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
||||
unsigned Reg = MO.getReg();
|
||||
const char *Name = RI.get(Reg).Name;
|
||||
switch (Mode) {
|
||||
default: return true; // Unknown mode.
|
||||
case 'b': // Print QImode register
|
||||
switch (Reg) {
|
||||
default: return true;
|
||||
case X86::AH: case X86::AL: case X86::AX: case X86::EAX:
|
||||
Name = "AL";
|
||||
break;
|
||||
case X86::DH: case X86::DL: case X86::DX: case X86::EDX:
|
||||
Name = "DL";
|
||||
break;
|
||||
case X86::CH: case X86::CL: case X86::CX: case X86::ECX:
|
||||
Name = "CL";
|
||||
break;
|
||||
case X86::BH: case X86::BL: case X86::BX: case X86::EBX:
|
||||
Name = "BL";
|
||||
break;
|
||||
case X86::ESI:
|
||||
Name = "SIL";
|
||||
break;
|
||||
case X86::EDI:
|
||||
Name = "DIL";
|
||||
break;
|
||||
case X86::EBP:
|
||||
Name = "BPL";
|
||||
break;
|
||||
case X86::ESP:
|
||||
Name = "SPL";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'h': // Print QImode high register
|
||||
switch (Reg) {
|
||||
default: return true;
|
||||
case X86::AH: case X86::AL: case X86::AX: case X86::EAX:
|
||||
Name = "AL";
|
||||
break;
|
||||
case X86::DH: case X86::DL: case X86::DX: case X86::EDX:
|
||||
Name = "DL";
|
||||
break;
|
||||
case X86::CH: case X86::CL: case X86::CX: case X86::ECX:
|
||||
Name = "CL";
|
||||
break;
|
||||
case X86::BH: case X86::BL: case X86::BX: case X86::EBX:
|
||||
Name = "BL";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'w': // Print HImode register
|
||||
switch (Reg) {
|
||||
default: return true;
|
||||
case X86::AH: case X86::AL: case X86::AX: case X86::EAX:
|
||||
Name = "AX";
|
||||
break;
|
||||
case X86::DH: case X86::DL: case X86::DX: case X86::EDX:
|
||||
Name = "DX";
|
||||
break;
|
||||
case X86::CH: case X86::CL: case X86::CX: case X86::ECX:
|
||||
Name = "CX";
|
||||
break;
|
||||
case X86::BH: case X86::BL: case X86::BX: case X86::EBX:
|
||||
Name = "BX";
|
||||
break;
|
||||
case X86::ESI:
|
||||
Name = "SI";
|
||||
break;
|
||||
case X86::EDI:
|
||||
Name = "DI";
|
||||
break;
|
||||
case X86::EBP:
|
||||
Name = "BP";
|
||||
break;
|
||||
case X86::ESP:
|
||||
Name = "SP";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'k': // Print SImode register
|
||||
switch (Reg) {
|
||||
default: return true;
|
||||
case X86::AH: case X86::AL: case X86::AX: case X86::EAX:
|
||||
Name = "EAX";
|
||||
break;
|
||||
case X86::DH: case X86::DL: case X86::DX: case X86::EDX:
|
||||
Name = "EDX";
|
||||
break;
|
||||
case X86::CH: case X86::CL: case X86::CX: case X86::ECX:
|
||||
Name = "ECX";
|
||||
break;
|
||||
case X86::BH: case X86::BL: case X86::BX: case X86::EBX:
|
||||
Name = "EBX";
|
||||
break;
|
||||
case X86::ESI:
|
||||
Name = "ESI";
|
||||
break;
|
||||
case X86::EDI:
|
||||
Name = "EDI";
|
||||
break;
|
||||
case X86::EBP:
|
||||
Name = "EBP";
|
||||
break;
|
||||
case X86::ESP:
|
||||
Name = "ESP";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
O << '%' << Name;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// PrintAsmOperand - Print out an operand for an inline asm expression.
|
||||
///
|
||||
bool X86IntelAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
@ -253,6 +370,11 @@ bool X86IntelAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
|
||||
switch (ExtraCode[0]) {
|
||||
default: return true; // Unknown modifier.
|
||||
case 'b': // Print QImode register
|
||||
case 'h': // Print QImode high register
|
||||
case 'w': // Print HImode register
|
||||
case 'k': // Print SImode register
|
||||
return printAsmMRegsiter(MI->getOperand(OpNo), ExtraCode[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
|
||||
printMemReference(MI, OpNo);
|
||||
}
|
||||
|
||||
bool printAsmMRegsiter(const MachineOperand &MO, const char Mode);
|
||||
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
unsigned AsmVariant, const char *ExtraCode);
|
||||
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
|
Loading…
Reference in New Issue
Block a user