On 22 May 2017, at 10:55 AM, Jacob Bachmeyer <jcb6...@gmail.com> wrote:Dave Williams wrote:While working with the RiscV assembler (binutils version 2.28.51) - I discovered a 'feature'. My HDL test bench (Verilog HDL) revealed that the following RiscV base instructions can be invoked without all register operands.
[...]
My proposal is that for RiscV assembler, a command line option be added that would turn off this assembler feature of making these conversions. The existing functionality of the assembler would remain untouched and the assembler would default to the current operation of making these types of conversions. But, a new RiscV command line option would be added that enforces strict operand usage.
So if this new feature was invoked SLT regX,regY,imm or the example
slt x10,x11,12
would ether fail or at least warn that the operands are not technically correct.
My motivations for proposing this change are as follows. When you are implementing and verifying a synthesizable RiscV core - initially, I find it essential to work as close to the base instructions as possible. Adding more abstractions - even pseudoinstructions - only add to the difficulty of this task (I am not advocating any changes to the specified pseudoinstructions). I initially will verify instruction decode logic at the machine level and lean heavily on my assembly output listing. When I discovered this assembler feature, I found it to be a distraction and not of much value to me. Basically, I was left wondering why didn't the assembler enforce the correct operands for these base instructions? For those who want to see more details - GitHub riscv/riscv-binutils-gdb #79 contains discussion and executable test cases as well as a test case revealing a bug in 'objcopy' that should be resolved in #80. I had list file output that contained the mnemonic SLT paired along side SLTI machine code. Palmer and Andrew jumped on this hitch in 'objcopy' and after I reviewed the diff - it looks like this problem should be resolved in the next branch. When I proposed giving the user the option of turning off this feature in the the assembler, Palmer suggested I post my new feature request to this list. This appears to be a carryover feature from MIPS and there maybe some legacy reason why the assembler works this way. But speaking as a core implementer or as a implementor of any executable model of a RiscV core - where I am using assembly to create test stimulus - I see no value in this feature. Initially, my mantra is " Keep-It-Simple". So, I am soliciting feedback and comments.
I would suggest a further step in typo-proofing: require immediates to be prefixed with either # (for decimal) or $ (for hexadecimal). Register names in RISC-V are systematic enough that a % prefix is probably unneeded, but might also be advisable.
If backwards compatibility prevents this change in all cases, I propose adding an "-mstrict-operands" option to the assembler. When "-mstrict-operands" (or an equivalent ".set strict-operands"?) is in force, the assembler would require prefix characters on registers and immediates. CSR names would be treated as symbols, rather than registers, because they are unambiguous due to the special CSR access instructions, but referencing a CSR by number would be considered an immediate. The assembler would always accept prefix characters, but would only require them if "strict-operands" is in effect.
-- Jacob
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/59221AFD.5080408%40gmail.com.
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFx0xxiUZbU4oKzNzFLnj73d_25SYsyP2AJfkFdHMFZORedW3w%40mail.gmail.com.
This behaviour is inherited from MIPS assembly where "add $2,$4,13" produces the same opcode 2482000d as "addi $2,$4,13" (or "addi v0,a0,13").Actually, it works elsewhere with gnu as too:arm: add r0, r0, 13 => f100 000d add.w r0, r0, #13 (omitting the #)arm64: add w0, w0, 13 => 11003400 add w0, w0, #0xdI suspect askng RISC-V gnu as to omit this handy and common shortcut is unlikely to gain much traction. Assembly language is a sharp knife, use carefully :-)
--
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFx0xxg%3Ddp%3D6cvk6yXMNkA%3DSfR%3Dc8SJdo--XD9wnY_AyLmjceA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/a62b270e-bfc7-45ba-8b97-0b7e351de686%40groups.riscv.org.
Michael Clark wrote:
The aliases for immediate versions are unfortunate as it prevents an assembler that reflects on specification metadata, as I tried to do. Even if GCC is changed to emit the “canonical form” for the immediate mode instructions, the aliases will need to be maintained in binutils for some time, perhaps forever.
This is why I proposed a "strict-operands" assembler flag to select the new behavior.
-- Jacob
On 23 May 2017, at 9:41 AM, Michael Clark <michae...@mac.com <mailto:michae...@mac.com>> wrote:
$ for numeric literals and % for register names are required by current gas (gnu assembler) in the default AT&T mode for x86-64.
The main concern will be compatibility between the compiler backends GCC/Clang/LLVM and binutils mainly because GCC and binutils/gas are maintained separately. I mention Clang/LLVM as they can be configured to either use the host assembler or the builtin integrated assembler.
Just to point out, C semantics interpret tokens starting with [0-9] as numbers and [a-zA-Z] as literals, so the current assembler semantics is no different to C semantics. I don’t think it should be changed.
Given the assembler already handles the canonical immediate opcodes, I would suggest the minimum change is actually in GCC and that is for it to emit the “i” version for instructions with immediate operands, then the assembly output would match the specification. This change would not require any change in binutils, rather it would require a GCC change. It’s a nit, but it would make the assembler output match the spec. I suspect LLVM may use the canonical form, as its assembler does not need to accept GCC output.
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFx0xxjTXQxpO9tHwdjhcprxC59nMfG1i%2BKF0mjz8j8n3pAdHw%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFx0xxjTXQxpO9tHwdjhcprxC59nMfG1i%2BKF0mjz8j8n3pAdHw%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/F2862C80-96DD-4BE7-9580-B5976D311AD6%40mac.com.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFx0xxhwMxzvy%2BRZOeGGYwZkoN%2B5NbS%2BthxMCpQ_fJ%2BLcdunUA%40mail.gmail.com.
On 24 May 2017, at 12:17 PM, Michael Clark <michae...@mac.com> wrote:This alias could perhaps be removed too (as “mv” is the canonical pseudo instruction):
- move mv
- jr jalr
On 25 May 2017, at 9:40 AM, Andrew Waterman <and...@sifive.com> wrote:On Wed, May 24, 2017 at 2:27 PM, Michael Clark <michae...@mac.com> wrote:Looks good!
I’m not fussed about the option name. -mstrict-operands is semantically correct.
It would be really nice if GCC was also emitting canonical RISC-V assembly. The nice thing is that the assembler accepts the canonical form so it will be a backwards compatible change.
I have a question about the GCC instruction selection metadata. I see expressions like this:
(define_insn "addsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(plus:SI (match_operand:SI 1 "register_operand" " r,r")
(match_operand:SI 2 "arith_operand" " r,I")))]
""
{ return TARGET_64BIT ? "addw\t%0,%1,%2" : "add\t%0,%1,%2"; }
[(set_attr "type" "arith")
(set_attr “mode” “SI”)
])
Is “arith_operand” a more general type that matches either a “register_operand” or “immediate_operand”?
Yeah, see predicates.md.
It seems then that we would need to split these “arith_operand” definitions into two definitions that specify either “register_operand” or “immediate_operand” instead of “arith_operand”?
We certainly do not want to split them up.
You can avoid doing so by adding a mode modifier, i, which prints the
letter 'i' if the corresponding operand is a constant. You'd change
the patterns to things like "add%i2\t%0,%1,%2", where %i2 means "print
the letter 'i' if operand 2 is a constant." The mode modifier is
implemented by adding another case to riscv_print_operand in riscv.c.
On 25 May 2017, at 9:40 AM, Andrew Waterman <and...@sifive.com> wrote:On Wed, May 24, 2017 at 2:27 PM, Michael Clark <michae...@mac.com> wrote:Looks good!
I’m not fussed about the option name. -mstrict-operands is semantically correct.
It would be really nice if GCC was also emitting canonical RISC-V assembly.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CA%2B%2B6G0D8UfYoPi25%3D7FRhTqePBxjTCXqDfvpLrDfiAPVxXOEGg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
On 25 May 2017, at 10:35 AM, Dave Williams <dave.will...@gmail.com> wrote:On Wed, May 24, 2017 at 3:45 PM, Michael Clark <michae...@mac.com> wrote:On 25 May 2017, at 9:40 AM, Andrew Waterman <and...@sifive.com> wrote:On Wed, May 24, 2017 at 2:27 PM, Michael Clark <michae...@mac.com> wrote:Looks good!
I’m not fussed about the option name. -mstrict-operands is semantically correct.
It would be really nice if GCC was also emitting canonical RISC-V assembly.When you say canonical RISC-V assembly do you mean emit base instructions only? (I am trying to synch up with your terminology). When I build with the RiscV GCC C compiler - I see base instructions and peudoinstructions in the list file output. Here's a snippet cut from a list file that contains many pseudoinstructions.
fc: 93070000 li x15,0
100: 13850700 mv x10,x15
104: 8320c134 lw x1,844(x2)
108: 03248134 lw x8,840(x2)
10c: 13010135 addi x2,x2,848
110: 67800000 retOf course the pseudoinstructions like ‘mv' will decompose into a base instruction.
| |||
| The response was: DNS Error: 4815150 DNS type 'mx' lookup of hoult.org responded with code SERVFAIL |
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/725cba38-6979-4e5d-ac67-a7be373c23b1%40groups.riscv.org.
Yeah :-( The site itself is up if you put it in your hosts file, but the 3rd party DNS has disappeared. I'm looking at how to replace that today -- long time since I had to play with that stuff. I'm reachable at bruce...@gmail.com if anyone cares.
On Sun, May 28, 2017 at 12:41 PM, Tommy Murphy <tommy_...@hotmail.com> wrote:
Me too.This is what I get:
Delivery incomplete
There was a temporary problem delivering your message to br...@hoult.org. Gmail will retry for 44 more hours. You'll be notified if the delivery fails permanently. The response was: DNS Error: 4815150 DNS type 'mx' lookup of hoult.org responded with code SERVFAIL
On Tuesday, 23 May 2017 23:52:01 UTC+1, Benjamin Herrenschmidt wrote:(Bruce Hoult, I had to take you out of the CC list, I'm getting
timeouts trying to reach your domain).
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
;; <insn> expands to the name of the insn that implements a particular code.(define_code_attr insn [(ashift "sll")(ashiftrt "sra")(lshiftrt "srl")(div "div")(mod "rem")(udiv "divu")(umod "remu")(ior "or")(xor "xor")(and "and")(plus "add")(minus “sub")])
On 25 May 2017, at 9:40 AM, Andrew Waterman <and...@sifive.com> wrote:
(define_insn "zero_extendqi<SUPERQI:mode>2"[(set (match_operand:SUPERQI 0 "register_operand" "=r,r")(zero_extend:SUPERQI(match_operand:QI 1 "nonimmediate_operand" " r,m")))]"""@andi\t%0,%1,0xfflbu\t%0,%1"[(set_attr "move_type" "andi,load")(set_attr "mode" "<SUPERQI:MODE>")])