Add RISC-V encodings for brz and brnz.

These branches compare a register to zero. RISC-V implements this with
the %x0 hard-coded zero register.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-03 15:20:57 -07:00
parent 479ff156c1
commit e641c97670
4 changed files with 32 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ from __future__ import absolute_import
from cdsl.isa import EncRecipe
from cdsl.predicates import IsSignedInt
from base.formats import Binary, BinaryImm, MultiAry, IntCompare, IntCompareImm
from base.formats import UnaryImm, BranchIcmp
from base.formats import UnaryImm, BranchIcmp, Branch
from .registers import GPR
# The low 7 bits of a RISC-V instruction is the base opcode. All 32-bit
@@ -116,3 +116,6 @@ U = EncRecipe(
# TODO: These instructions have a +/- 4 KB branch range. How to encode that
# constraint?
SB = EncRecipe('SB', BranchIcmp, ins=(GPR, GPR), outs=())
# SB-type branch instruction with rs2 fixed to zero.
SBzero = EncRecipe('SBzero', Branch, ins=(GPR), outs=())