1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[VE] Support logical operation instructions in MC layer

Summary:
Add regression tests of asmparser, mccodeemitter, and disassembler for
logical operation instructions. Also change asmparser to support CMOV
instruction. And, add new EQV/MRG/NND isntructions also.

Differential Revision: https://reviews.llvm.org/D81219
This commit is contained in:
Kazushi (Jam) Marukawa 2020-06-05 16:57:37 +02:00 committed by Simon Moll
parent b11af615da
commit e788281441
13 changed files with 346 additions and 0 deletions

View File

@ -689,6 +689,10 @@ StringRef VEAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
(Name[Next + 1] == 'd' || Name[Next + 1] == 's'))
ICC = false;
Mnemonic = parseCC(Name, Start, Next, ICC, true, NameLoc, Operands);
} else if (Name.startswith("cmov.l.") || Name.startswith("cmov.w.") ||
Name.startswith("cmov.d.") || Name.startswith("cmov.s.")) {
bool ICC = Name[5] == 'l' || Name[5] == 'w';
Mnemonic = parseCC(Name, 7, Name.size(), ICC, false, NameLoc, Operands);
} else {
Operands->push_back(VEOperand::CreateToken(Mnemonic, NameLoc));
}
@ -696,8 +700,16 @@ StringRef VEAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
return Mnemonic;
}
static void applyMnemonicAliases(StringRef &Mnemonic,
const FeatureBitset &Features,
unsigned VariantID);
bool VEAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
SMLoc NameLoc, OperandVector &Operands) {
// If the target architecture uses MnemonicAlias, call it here to parse
// operands correctly.
applyMnemonicAliases(Name, getAvailableFeatures(), 0);
// Split name to first token and the rest, e.g. "bgt.l.t" to "b", "gt", and
// ".l.t". We treat "b" as a mnemonic, "gt" as first operand, and ".l.t"
// as second operand.

View File

@ -506,6 +506,23 @@ multiclass RRI1m<string opcStr, bits<8>opc, RegisterClass RC, ValueType Ty,
[(set Ty:$sx, (OpNode (Ty mimm:$sz)))]>;
}
// Special RR multiclass for MRG instruction.
// e.g. MRG
let Constraints = "$sx = $sd", DisableEncoding = "$sd", hasSideEffects = 0 in
multiclass RRMRGm<string opcStr, bits<8>opc, RegisterClass RC, ValueType Ty> {
def rr : RR<opc, (outs RC:$sx), (ins RC:$sy, RC:$sz, RC:$sd),
!strconcat(opcStr, " $sx, $sy, $sz")>;
let cy = 0 in
def ir : RR<opc, (outs RC:$sx), (ins simm7:$sy, RC:$sz, RC:$sd),
!strconcat(opcStr, " $sx, $sy, $sz")>;
let cz = 0 in
def rm : RR<opc, (outs RC:$sx), (ins RC:$sy, mimm:$sz, RC:$sd),
!strconcat(opcStr, " $sx, $sy, $sz")>;
let cy = 0, cz = 0 in
def im : RR<opc, (outs RC:$sx), (ins simm7:$sy, mimm:$sz, RC:$sd),
!strconcat(opcStr, " $sx, $sy, $sz")>;
}
// Special RR multiclass for BSWP instruction.
// e.g. BSWP
let hasSideEffects = 0 in
@ -892,8 +909,13 @@ defm XOR : RRm<"xor", 0x46, I64, i64, xor>;
let isCodeGenOnly = 1 in defm XOR32 : RRm<"xor", 0x46, I32, i32, xor>;
// Section 8.5.4 - EQV (Equivalence)
defm EQV : RRm<"eqv", 0x47, I64, i64>;
// Section 8.5.5 - NND (Negate AND)
defm NND : RRNCm<"nnd", 0x54, I64, i64>;
// Section 8.5.6 - MRG (Merge)
defm MRG : RRMRGm<"mrg", 0x56, I64, i64>;
// Section 8.5.7 - LDZ (Leading Zero Count)
defm LDZ : RRI1m<"ldz", 0x67, I64, i64, ctlz>;
@ -912,6 +934,10 @@ let cw = 0, cw2 = 0 in defm CMOVL : RRCMOVm<"cmov.l.${cfw}", 0x3B, I64, i64>;
let cw = 1, cw2 = 0 in defm CMOVW : RRCMOVm<"cmov.w.${cfw}", 0x3B, I32, i32>;
let cw = 0, cw2 = 1 in defm CMOVD : RRCMOVm<"cmov.d.${cfw}", 0x3B, I64, f64>;
let cw = 1, cw2 = 1 in defm CMOVS : RRCMOVm<"cmov.s.${cfw}", 0x3B, F32, f32>;
def : MnemonicAlias<"cmov.l", "cmov.l.at">;
def : MnemonicAlias<"cmov.w", "cmov.w.at">;
def : MnemonicAlias<"cmov.d", "cmov.d.at">;
def : MnemonicAlias<"cmov.s", "cmov.s.at">;
//-----------------------------------------------------------------------------
// Section 8.6 - Shift Operation Instructions

28
test/MC/VE/AND.s Normal file
View File

@ -0,0 +1,28 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: and %s11, %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x8b,0x0b,0x44]
and %s11, %s11, %s11
# CHECK-INST: and %s11, 63, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x3f,0x0b,0x44]
and %s11, 63, %s11
# CHECK-INST: and %s11, -1, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x7f,0x0b,0x44]
and %s11, -1, %s11
# CHECK-INST: and %s11, -64, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x40,0x0b,0x44]
and %s11, -64, %s11
# CHECK-INST: and %s11, -64, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x40,0x0b,0x44]
and %s11, -64, (32)1
# CHECK-INST: and %s11, 63, (32)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x60,0x3f,0x0b,0x44]
and %s11, 63, (32)0

16
test/MC/VE/BRV.s Normal file
View File

@ -0,0 +1,16 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: brv %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x00,0x0b,0x39]
brv %s11, %s11
# CHECK-INST: brv %s11, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x00,0x0b,0x39]
brv %s11, (32)1
# CHECK-INST: brv %s11, (63)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x7f,0x00,0x0b,0x39]
brv %s11, (63)0

20
test/MC/VE/BSWP.s Normal file
View File

@ -0,0 +1,20 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: bswp %s11, %s11, 0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x00,0x0b,0x2b]
bswp %s11, %s11, 0
# CHECK-INST: bswp %s11, %s11, 1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x01,0x0b,0x2b]
bswp %s11, %s11, 1
# CHECK-INST: bswp %s11, (32)1, 0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x00,0x0b,0x2b]
bswp %s11, (32)1, 0
# CHECK-INST: bswp %s11, (32)0, 1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x60,0x01,0x0b,0x2b]
bswp %s11, (32)0, 1

72
test/MC/VE/CMOV.s Normal file
View File

@ -0,0 +1,72 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: cmov.l.at %s11, %s12, 63
# CHECK-ENCODING: encoding: [0x0f,0x00,0x00,0x00,0x8c,0x3f,0x0b,0x3b]
cmov.l %s11, %s12, 63
# CHECK-INST: cmov.w.at %s11, %s12, %s13
# CHECK-ENCODING: encoding: [0x8f,0x00,0x00,0x00,0x8c,0x8d,0x0b,0x3b]
cmov.w.at %s11, %s12, %s13
# CHECK-INST: cmov.d.af %s11, (20)0, %s12
# CHECK-ENCODING: encoding: [0x40,0x00,0x00,0x00,0x54,0x8c,0x0b,0x3b]
cmov.d.af %s11, (20)0, %s12
# CHECK-INST: cmov.s.gt %s11, (63)1, %s12
# CHECK-ENCODING: encoding: [0xc1,0x00,0x00,0x00,0x3f,0x8c,0x0b,0x3b]
cmov.s.gt %s11, (63)1, %s12
# CHECK-INST: cmov.l.lt %s11, %s12, 63
# CHECK-ENCODING: encoding: [0x02,0x00,0x00,0x00,0x8c,0x3f,0x0b,0x3b]
cmov.l.lt %s11, %s12, 63
# CHECK-INST: cmov.w.ne %s11, %s12, %s13
# CHECK-ENCODING: encoding: [0x83,0x00,0x00,0x00,0x8c,0x8d,0x0b,0x3b]
cmov.w.ne %s11, %s12, %s13
# CHECK-INST: cmov.d.eq %s11, (20)0, %s12
# CHECK-ENCODING: encoding: [0x44,0x00,0x00,0x00,0x54,0x8c,0x0b,0x3b]
cmov.d.eq %s11, (20)0, %s12
# CHECK-INST: cmov.s.ge %s11, (63)1, %s12
# CHECK-ENCODING: encoding: [0xc5,0x00,0x00,0x00,0x3f,0x8c,0x0b,0x3b]
cmov.s.ge %s11, (63)1, %s12
# CHECK-INST: cmov.l.le %s11, %s12, 63
# CHECK-ENCODING: encoding: [0x06,0x00,0x00,0x00,0x8c,0x3f,0x0b,0x3b]
cmov.l.le %s11, %s12, 63
# CHECK-INST: cmov.d.num %s11, %s12, %s13
# CHECK-ENCODING: encoding: [0x47,0x00,0x00,0x00,0x8c,0x8d,0x0b,0x3b]
cmov.d.num %s11, %s12, %s13
# CHECK-INST: cmov.s.nan %s11, (63)1, %s12
# CHECK-ENCODING: encoding: [0xc8,0x00,0x00,0x00,0x3f,0x8c,0x0b,0x3b]
cmov.s.nan %s11, (63)1, %s12
# CHECK-INST: cmov.d.gtnan %s11, %s12, %s13
# CHECK-ENCODING: encoding: [0x49,0x00,0x00,0x00,0x8c,0x8d,0x0b,0x3b]
cmov.d.gtnan %s11, %s12, %s13
# CHECK-INST: cmov.s.ltnan %s11, (63)1, %s12
# CHECK-ENCODING: encoding: [0xca,0x00,0x00,0x00,0x3f,0x8c,0x0b,0x3b]
cmov.s.ltnan %s11, (63)1, %s12
# CHECK-INST: cmov.d.nenan %s11, %s12, %s13
# CHECK-ENCODING: encoding: [0x4b,0x00,0x00,0x00,0x8c,0x8d,0x0b,0x3b]
cmov.d.nenan %s11, %s12, %s13
# CHECK-INST: cmov.s.eqnan %s11, (63)1, %s12
# CHECK-ENCODING: encoding: [0xcc,0x00,0x00,0x00,0x3f,0x8c,0x0b,0x3b]
cmov.s.eqnan %s11, (63)1, %s12
# CHECK-INST: cmov.d.genan %s11, %s12, %s13
# CHECK-ENCODING: encoding: [0x4d,0x00,0x00,0x00,0x8c,0x8d,0x0b,0x3b]
cmov.d.genan %s11, %s12, %s13
# CHECK-INST: cmov.s.lenan %s11, (63)1, %s12
# CHECK-ENCODING: encoding: [0xce,0x00,0x00,0x00,0x3f,0x8c,0x0b,0x3b]
cmov.s.lenan %s11, (63)1, %s12

28
test/MC/VE/EQV.s Normal file
View File

@ -0,0 +1,28 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: eqv %s11, %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x8b,0x0b,0x47]
eqv %s11, %s11, %s11
# CHECK-INST: eqv %s11, 63, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x3f,0x0b,0x47]
eqv %s11, 63, %s11
# CHECK-INST: eqv %s11, -1, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x7f,0x0b,0x47]
eqv %s11, -1, %s11
# CHECK-INST: eqv %s11, -64, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x40,0x0b,0x47]
eqv %s11, -64, %s11
# CHECK-INST: eqv %s11, -64, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x40,0x0b,0x47]
eqv %s11, -64, (32)1
# CHECK-INST: eqv %s11, 63, (32)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x60,0x3f,0x0b,0x47]
eqv %s11, 63, (32)0

16
test/MC/VE/LDZ.s Normal file
View File

@ -0,0 +1,16 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: ldz %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x00,0x0b,0x67]
ldz %s11, %s11
# CHECK-INST: ldz %s11, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x00,0x0b,0x67]
ldz %s11, (32)1
# CHECK-INST: ldz %s11, (63)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x7f,0x00,0x0b,0x67]
ldz %s11, (63)0

28
test/MC/VE/MRG.s Normal file
View File

@ -0,0 +1,28 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: mrg %s11, %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x8b,0x0b,0x56]
mrg %s11, %s11, %s11
# CHECK-INST: mrg %s11, 63, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x3f,0x0b,0x56]
mrg %s11, 63, %s11
# CHECK-INST: mrg %s11, -1, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x7f,0x0b,0x56]
mrg %s11, -1, %s11
# CHECK-INST: mrg %s11, -64, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x40,0x0b,0x56]
mrg %s11, -64, %s11
# CHECK-INST: mrg %s11, -64, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x40,0x0b,0x56]
mrg %s11, -64, (32)1
# CHECK-INST: mrg %s11, 63, (32)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x60,0x3f,0x0b,0x56]
mrg %s11, 63, (32)0

28
test/MC/VE/NND.s Normal file
View File

@ -0,0 +1,28 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: nnd %s11, %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x8b,0x0b,0x54]
nnd %s11, %s11, %s11
# CHECK-INST: nnd %s11, 63, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x3f,0x0b,0x54]
nnd %s11, 63, %s11
# CHECK-INST: nnd %s11, -1, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x7f,0x0b,0x54]
nnd %s11, -1, %s11
# CHECK-INST: nnd %s11, -64, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x40,0x0b,0x54]
nnd %s11, -64, %s11
# CHECK-INST: nnd %s11, -64, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x40,0x0b,0x54]
nnd %s11, -64, (32)1
# CHECK-INST: nnd %s11, 63, (32)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x60,0x3f,0x0b,0x54]
nnd %s11, 63, (32)0

28
test/MC/VE/OR.s Normal file
View File

@ -0,0 +1,28 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: or %s11, %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x8b,0x0b,0x45]
or %s11, %s11, %s11
# CHECK-INST: or %s11, 63, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x3f,0x0b,0x45]
or %s11, 63, %s11
# CHECK-INST: or %s11, -1, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x7f,0x0b,0x45]
or %s11, -1, %s11
# CHECK-INST: or %s11, -64, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x40,0x0b,0x45]
or %s11, -64, %s11
# CHECK-INST: or %s11, -64, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x40,0x0b,0x45]
or %s11, -64, (32)1
# CHECK-INST: or %s11, 63, (32)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x60,0x3f,0x0b,0x45]
or %s11, 63, (32)0

16
test/MC/VE/PCNT.s Normal file
View File

@ -0,0 +1,16 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: pcnt %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x00,0x0b,0x38]
pcnt %s11, %s11
# CHECK-INST: pcnt %s11, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x00,0x0b,0x38]
pcnt %s11, (32)1
# CHECK-INST: pcnt %s11, (63)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x7f,0x00,0x0b,0x38]
pcnt %s11, (63)0

28
test/MC/VE/XOR.s Normal file
View File

@ -0,0 +1,28 @@
# RUN: llvm-mc -triple=ve --show-encoding < %s \
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
# RUN: | FileCheck %s --check-prefixes=CHECK-INST
# CHECK-INST: xor %s11, %s11, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x8b,0x0b,0x46]
xor %s11, %s11, %s11
# CHECK-INST: xor %s11, 63, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x3f,0x0b,0x46]
xor %s11, 63, %s11
# CHECK-INST: xor %s11, -1, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x7f,0x0b,0x46]
xor %s11, -1, %s11
# CHECK-INST: xor %s11, -64, %s11
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x8b,0x40,0x0b,0x46]
xor %s11, -64, %s11
# CHECK-INST: xor %s11, -64, (32)1
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x20,0x40,0x0b,0x46]
xor %s11, -64, (32)1
# CHECK-INST: xor %s11, 63, (32)0
# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x60,0x3f,0x0b,0x46]
xor %s11, 63, (32)0