diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.h b/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.h --- a/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.h +++ b/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.h @@ -13,6 +13,7 @@ #ifndef LLVM_LIB_TARGET_VE_INSTPRINTER_VEINSTPRINTER_H #define LLVM_LIB_TARGET_VE_INSTPRINTER_VEINSTPRINTER_H +#include "VEMCTargetDesc.h" #include "llvm/MC/MCInstPrinter.h" namespace llvm { @@ -32,7 +33,8 @@ const MCSubtargetInfo &, raw_ostream &); void printInstruction(const MCInst *, uint64_t, const MCSubtargetInfo &, raw_ostream &); - static const char *getRegisterName(unsigned RegNo); + static const char *getRegisterName(unsigned RegNo, + unsigned AltIdx = VE::NoRegAltName); void printOperand(const MCInst *MI, int OpNum, const MCSubtargetInfo &STI, raw_ostream &OS); diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp --- a/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp +++ b/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp @@ -36,7 +36,9 @@ #include "VEGenAsmWriter.inc" void VEInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const { - OS << '%' << StringRef(getRegisterName(RegNo)).lower(); + // Generic registers have identical register name among register classes. + unsigned AltIdx = VE::AsmName; + OS << '%' << StringRef(getRegisterName(RegNo, AltIdx)).lower(); } void VEInstPrinter::printInst(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/VE/VERegisterInfo.td b/llvm/lib/Target/VE/VERegisterInfo.td --- a/llvm/lib/Target/VE/VERegisterInfo.td +++ b/llvm/lib/Target/VE/VERegisterInfo.td @@ -10,10 +10,14 @@ // Declarations that describe the VE register file //===----------------------------------------------------------------------===// -class VEReg Enc, string n> : Register { +class VEReg enc, string n, list subregs = [], + list altNames = [], list aliases = []> + : Register { let HWEncoding{15-7} = 0; - let HWEncoding{6-0} = Enc; + let HWEncoding{6-0} = enc; let Namespace = "VE"; + let SubRegs = subregs; + let Aliases = aliases; } let Namespace = "VE" in { @@ -21,41 +25,45 @@ def sub_i16 : SubRegIndex<16, 48>; // Low 16 bit (48..63) def sub_i32 : SubRegIndex<32, 32>; // Low 32 bit (32..63) def sub_f32 : SubRegIndex<32>; // High 32 bit (0..31) + def AsmName : RegAltNameIndex; } -// Registers are identified with 7-bit ID numbers. -// R - 64-bit integer or floating-point registers -class R Enc, string n, list subregs = [], - list aliases = []>: VEReg { - let SubRegs = subregs; - let Aliases = aliases; -} +//----------------------------------------------------------------------------- +// Gneric Registers +//----------------------------------------------------------------------------- + +let RegAltNameIndices = [AsmName] in { // Generic integer registers - 8 bits wide foreach I = 0-63 in - def SB#I : R, DwarfRegNum<[I]>; + def SB#I : VEReg, DwarfRegNum<[I]>; // Generic integer registers - 16 bits wide let SubRegIndices = [sub_i8] in foreach I = 0-63 in - def SH#I : R("SB"#I)]>, DwarfRegNum<[I]>; + def SH#I : VEReg("SB"#I)], ["s"#I]>, + DwarfRegNum<[I]>; // Generic integer registers - 32 bits wide let SubRegIndices = [sub_i16] in foreach I = 0-63 in - def SW#I : R("SH"#I)]>, DwarfRegNum<[I]>; + def SW#I : VEReg("SH"#I)], ["s"#I]>, + DwarfRegNum<[I]>; // Generic floating point registers - 32 bits wide // NOTE: Mark SF#I as alias of SW#I temporary to avoid register allocation // problem. foreach I = 0-63 in - def SF#I : R("SW"#I)]>, DwarfRegNum<[I]>; + def SF#I : VEReg("SW"#I)]>, + DwarfRegNum<[I]>; // Generic integer registers - 64 bits wide let SubRegIndices = [sub_i32, sub_f32], CoveredBySubRegs = 1 in foreach I = 0-63 in - def SX#I : R("SW"#I), !cast("SF"#I)]>, - DwarfRegNum<[I]>; + def SX#I : VEReg("SW"#I), !cast("SF"#I)], + ["s"#I]>, DwarfRegNum<[I]>; + +} // RegAltNameIndices = [AsmName] // Register classes. //