Add Intel encodings for ifcmp_sp.

Also generate an Into<RegUnit> implementation for the RU enums.
This commit is contained in:
Jakob Stoklund Olesen
2018-02-09 14:32:29 -08:00
parent 73c4c356c9
commit 788a78caf4
9 changed files with 34 additions and 8 deletions

View File

@@ -534,5 +534,11 @@ ebb1:
; asm: jnbe .+4; ud2 ; asm: jnbe .+4; ud2
trapif ule v11, user0 ; bin: 77 02 0f 0b trapif ule v11, user0 ; bin: 77 02 0f 0b
; Stack check.
; asm: cmpl %esp, %ecx
[-,%eflags] v40 = ifcmp_sp v1 ; bin: 39 e1
; asm: cmpl %esp, %esi
[-,%eflags] v41 = ifcmp_sp v2 ; bin: 39 e6
return return
} }

View File

@@ -615,6 +615,12 @@ ebb1:
; asm: jnbe .+4; ud2 ; asm: jnbe .+4; ud2
trapif ule v11, user0 ; bin: 77 02 0f 0b trapif ule v11, user0 ; bin: 77 02 0f 0b
; Stack check.
; asm: cmpq %rsp, %rcx
[-,%eflags] v40 = ifcmp_sp v1 ; bin: 48 39 e1
; asm: cmpq %rsp, %r10
[-,%eflags] v41 = ifcmp_sp v2 ; bin: 49 39 e2
return return
} }

View File

@@ -96,6 +96,9 @@ def gen_isa(isa, fmt):
with fmt.indented('pub enum RU {', '}'): with fmt.indented('pub enum RU {', '}'):
for regbank in isa.regbanks: for regbank in isa.regbanks:
gen_regbank_units(regbank, fmt) gen_regbank_units(regbank, fmt)
with fmt.indented('impl Into<RegUnit> for RU {', '}'):
with fmt.indented('fn into(self) -> RegUnit {', '}'):
fmt.line('self as RegUnit')
def generate(isas, out_dir): def generate(isas, out_dir):

View File

@@ -364,6 +364,9 @@ I64.enc(base.trapif, r.trapif, 0)
enc_i32_i64(base.icmp, r.icscc, 0x39) enc_i32_i64(base.icmp, r.icscc, 0x39)
enc_i32_i64(base.ifcmp, r.rcmp, 0x39) enc_i32_i64(base.ifcmp, r.rcmp, 0x39)
I32.enc(base.ifcmp_sp.i32, *r.rcmp_sp(0x39))
I64.enc(base.ifcmp_sp.i64, *r.rcmp_sp.rex(0x39, w=1))
# #
# Convert flags to bool. # Convert flags to bool.
# #

View File

@@ -517,8 +517,8 @@ adjustsp8 = TailRecipe(
'adjustsp8', UnaryImm, size=2, ins=(), outs=(), 'adjustsp8', UnaryImm, size=2, ins=(), outs=(),
instp=IsSignedInt(UnaryImm.imm, 8), instp=IsSignedInt(UnaryImm.imm, 8),
emit=''' emit='''
PUT_OP(bits, rex1(4), sink); PUT_OP(bits, rex1(RU::rsp.into()), sink);
modrm_r_bits(4, bits, sink); modrm_r_bits(RU::rsp.into(), bits, sink);
let imm: i64 = imm.into(); let imm: i64 = imm.into();
sink.put1(imm as u8); sink.put1(imm as u8);
''') ''')
@@ -527,8 +527,8 @@ adjustsp32 = TailRecipe(
'adjustsp32', UnaryImm, size=5, ins=(), outs=(), 'adjustsp32', UnaryImm, size=5, ins=(), outs=(),
instp=IsSignedInt(UnaryImm.imm, 32), instp=IsSignedInt(UnaryImm.imm, 32),
emit=''' emit='''
PUT_OP(bits, rex1(4), sink); PUT_OP(bits, rex1(RU::rsp.into()), sink);
modrm_r_bits(4, bits, sink); modrm_r_bits(RU::rsp.into(), bits, sink);
let imm: i64 = imm.into(); let imm: i64 = imm.into();
sink.put4(imm as u32); sink.put4(imm as u32);
''') ''')
@@ -1081,6 +1081,14 @@ fcmp = TailRecipe(
modrm_rr(in_reg1, in_reg0, sink); modrm_rr(in_reg1, in_reg0, sink);
''') ''')
# Same as rcmp, but second operand is the stack pointer.
rcmp_sp = TailRecipe(
'rcmp_sp', Unary, size=1, ins=GPR, outs=FLAG.eflags,
emit='''
PUT_OP(bits, rex2(in_reg0, RU::rsp.into()), sink);
modrm_rr(in_reg0, RU::rsp.into(), sink);
''')
# Test-and-branch. # Test-and-branch.
# #
# This recipe represents the macro fusion of a test and a conditional branch. # This recipe represents the macro fusion of a test and a conditional branch.

View File

@@ -1,6 +1,6 @@
//! ARM32 register descriptions. //! ARM32 register descriptions.
use isa::registers::{RegBank, RegClass, RegClassData, RegInfo}; use isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit};
include!(concat!(env!("OUT_DIR"), "/registers-arm32.rs")); include!(concat!(env!("OUT_DIR"), "/registers-arm32.rs"));

View File

@@ -1,6 +1,6 @@
//! ARM64 register descriptions. //! ARM64 register descriptions.
use isa::registers::{RegBank, RegClass, RegClassData, RegInfo}; use isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit};
include!(concat!(env!("OUT_DIR"), "/registers-arm64.rs")); include!(concat!(env!("OUT_DIR"), "/registers-arm64.rs"));

View File

@@ -1,6 +1,6 @@
//! Intel register descriptions. //! Intel register descriptions.
use isa::registers::{RegBank, RegClass, RegClassData, RegInfo}; use isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit};
include!(concat!(env!("OUT_DIR"), "/registers-intel.rs")); include!(concat!(env!("OUT_DIR"), "/registers-intel.rs"));

View File

@@ -1,6 +1,6 @@
//! RISC-V register descriptions. //! RISC-V register descriptions.
use isa::registers::{RegBank, RegClass, RegClassData, RegInfo}; use isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit};
include!(concat!(env!("OUT_DIR"), "/registers-riscv.rs")); include!(concat!(env!("OUT_DIR"), "/registers-riscv.rs"));