<div dir="ltr"><div><div>Hi Krzystof,<br><br></div>regarding your first solution (creating separate instruction), is it possible to somehow have cascading defm?<br></div>for example, let's suppose aaa is a 3-bit condition a, and bb is a 2-bit condition b, all in one instruction, instead of having one multiclass with 2^5 conditions, is it possible to write 2^3 "a" conditions, and 2^2 "b" conditions, and the rest taken care by the TableGen?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 10, 2015 at 5:59 PM, Krzysztof Parzyszek <span dir="ltr"><<a href="mailto:kparzysz@codeaurora.org" target="_blank">kparzysz@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 7/10/2015 10:23 AM, Sky Flyer wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Many thanks for your prompt reply.<br>
<br>
I mean, imagine you have 3 bits for condition flags in your instruction<br>
(e.g.  overflow, zero, carry set, ...) for conditional executions AND<br>
there is no direct access to the Status Register, is it even possible to<br>
implement such scenario?<br>
<br>
</blockquote>
<br></span>
There doesn't have to be any explicit status register.  You can either create separate instructions for each condition, or have the condition as an extra operand.  Let's take "add" for example.  You could have several versions of add:<br>
  add     add unconditionally<br>
  addc    add if carry<br>
  addz    add if zero<br>
  addo    add if overflow<br>
and similarly for more complex conditions that your target could support, such as "carry or zero".  This has the disadvantage that the instruction set can get really large, but if the number of conditional instructions is small or if the possible conditions vary from one operation to another, this may be a viable solution.<br>
The other option is to model the condition as an operand (I think ARM does that).  So the add instruction could look like this:<br>
  R0 = add R1, R2, C<br>
where<br>
  C = 0: no conditions<br>
  C = 1: zero<br>
  C = 2: carry<br>
  C = 4: overflow<br>
etc.<br>
<br>
This way the instruction set would remain small, but it may involve special handling for it to work with the integrated assembler (if the native instruction format is different than what you chose).<br>
<br>
You could use the TSFlags to indicate for each instruction which condition this instruction can modify.  Taking the add again, it could modify all of the three: zero, carry and overflow, but a load could only modify zero (for example, specifics would depend on your target).<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
-Krzysztof<br>
<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>