diff options
author | Alec Roelke <ar4jc@virginia.edu> | 2017-11-29 14:04:11 -0500 |
---|---|---|
committer | Alec Roelke <ar4jc@virginia.edu> | 2017-11-30 03:58:49 +0000 |
commit | 937ed3a0a26002bc5e015c23ecd805e4e32b2cca (patch) | |
tree | 51187af69c471a7ca82f5e94f142ef18fd507577 /src/arch/riscv/isa/formats/mem.isa | |
parent | aed69fec188b8789675a4d3d1a712b42d4cf4f75 (diff) | |
download | gem5-937ed3a0a26002bc5e015c23ecd805e4e32b2cca.tar.xz |
arch-riscv: use sext rather than manual masks
Replace manual creation of masks for sign extension of immediates with
the sext<N> function.
Change-Id: Ief2df91a25500c64f5bcae0dcd437c1e3bb95e6c
Reviewed-on: https://gem5-review.googlesource.com/6182
Reviewed-by: Alec Roelke <ar4jc@virginia.edu>
Maintainer: Alec Roelke <ar4jc@virginia.edu>
Diffstat (limited to 'src/arch/riscv/isa/formats/mem.isa')
-rw-r--r-- | src/arch/riscv/isa/formats/mem.isa | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/arch/riscv/isa/formats/mem.isa b/src/arch/riscv/isa/formats/mem.isa index 2cb2f18b4..11b6c4238 100644 --- a/src/arch/riscv/isa/formats/mem.isa +++ b/src/arch/riscv/isa/formats/mem.isa @@ -254,25 +254,17 @@ def template StoreCompleteAcc {{ } }}; -def format Load(memacc_code, ea_code={{EA = Rs1 + offset;}}, mem_flags=[], - inst_flags=[]) {{ - offset_code = """ - offset = IMM12; - if (IMMSIGN > 0) - offset |= ~((uint64_t)0xFFF); - """ +def format Load(memacc_code, ea_code = {{EA = Rs1 + offset;}}, + offset_code={{offset = sext<12>(IMM12);}}, + mem_flags=[], inst_flags=[]) {{ (header_output, decoder_output, decode_block, exec_output) = \ LoadStoreBase(name, Name, offset_code, ea_code, memacc_code, mem_flags, inst_flags, 'Load', exec_template_base='Load') }}; -def format Store(memacc_code, ea_code={{EA = Rs1 + offset;}}, mem_flags=[], - inst_flags=[]) {{ - offset_code = """ - offset = IMM5 | (IMM7 << 5); - if (IMMSIGN > 0) - offset |= ~((uint64_t)0xFFF); - """ +def format Store(memacc_code, ea_code={{EA = Rs1 + offset;}}, + offset_code={{offset = sext<12>(IMM5 | (IMM7 << 5));}}, + mem_flags=[], inst_flags=[]) {{ (header_output, decoder_output, decode_block, exec_output) = \ LoadStoreBase(name, Name, offset_code, ea_code, memacc_code, mem_flags, inst_flags, 'Store', exec_template_base='Store') |