<div dir="ltr">I'm missing the AsmPrinter to be able to do this IIUC (I'm not very familiar with Target-side things, correct me if I'm wrong!). I'll do that next, keeping the list of instructions small for now and working my way to these llc tests.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 14, 2015 at 5:26 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">With this you should be able to add a llc test, no?<br>
<div class="HOEnZb"><div class="h5"><br>
On 14 July 2015 at 14:13, JF Bastien <<a href="mailto:jfb@google.com">jfb@google.com</a>> wrote:<br>
> Author: jfb<br>
> Date: Tue Jul 14 16:13:29 2015<br>
> New Revision: 242201<br>
><br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D242201-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=p6AgDrp7Et72GfhcUaiXPpvrsDDHNlBTfR5z4j0YweY&s=x8LDxNrGtEDt-ecpL5ZFBVAgpzpCTq5h3K-S2Ga74os&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=242201&view=rev</a><br>
> Log:<br>
> WebAssembly: add basic int/fp instruction codegen.<br>
><br>
> Summary: This patch has the most basic instruction codegen for 32 and 64 bit int/fp.<br>
><br>
> Reviewers: sunfish<br>
><br>
> Subscribers: llvm-commits, jfb<br>
><br>
> Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D11193&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=p6AgDrp7Et72GfhcUaiXPpvrsDDHNlBTfR5z4j0YweY&s=kXvoBC2NBFKva3Pr-U5wspK4odhAwYQ76X4s5LGzgXw&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11193</a><br>
><br>
> Modified:<br>
>     llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFloat.td<br>
>     llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFormats.td<br>
>     llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td<br>
><br>
> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFloat.td<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Target_WebAssembly_WebAssemblyInstrFloat.td-3Frev-3D242201-26r1-3D242200-26r2-3D242201-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=p6AgDrp7Et72GfhcUaiXPpvrsDDHNlBTfR5z4j0YweY&s=xmlNlWXsMBW3hmm3ruJn7mNCvQEaA934i1QOA88DlcE&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFloat.td?rev=242201&r1=242200&r2=242201&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFloat.td (original)<br>
> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFloat.td Tue Jul 14 16:13:29 2015<br>
> @@ -12,26 +12,33 @@<br>
>  ///<br>
>  //===----------------------------------------------------------------------===//<br>
><br>
> +defm FADD : BinaryFP<fadd>;<br>
> +defm FSUB : BinaryFP<fsub>;<br>
> +defm FMUL : BinaryFP<fmul>;<br>
> +defm FDIV : BinaryFP<fdiv>;<br>
> +defm FABS : UnaryFP<fabs>;<br>
> +defm FNEG : UnaryFP<fneg>;<br>
> +defm COPYSIGN : BinaryFP<fcopysign>;<br>
> +defm CEIL : UnaryFP<fceil>;<br>
> +defm FLOOR : UnaryFP<ffloor>;<br>
> +defm TRUNC : UnaryFP<ftrunc>;<br>
> +defm NEARESTINT : UnaryFP<fnearbyint>;<br>
> +<br>
>  /*<br>
>   * TODO(jfb): Add the following for 32-bit and 64-bit.<br>
>   *<br>
> - * float32.add: addition<br>
> - * float32.sub: subtraction<br>
> - * float32.mul: multiplication<br>
> - * float32.div: division<br>
> - * float32.abs: absolute value<br>
> - * float32.neg: negation<br>
> - * float32.copysign: copysign<br>
> - * float32.ceil: ceiling operation<br>
> - * float32.floor: floor operation<br>
> - * float32.trunc: round to nearest integer towards zero<br>
> - * float32.nearestint: round to nearest integer, ties to even<br>
>   * float32.eq: compare equal<br>
>   * <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__float32.lt&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=p6AgDrp7Et72GfhcUaiXPpvrsDDHNlBTfR5z4j0YweY&s=ngaexWbWDUeogNXiTHKGoiMPuk4fPqxXlQ6OsA9-Ewk&e=" rel="noreferrer" target="_blank">float32.lt</a>: less than<br>
>   * float32.le: less than or equal<br>
>   * <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__float32.gt&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=p6AgDrp7Et72GfhcUaiXPpvrsDDHNlBTfR5z4j0YweY&s=Qhvf-vEDVgLA7pVe_eWNvYCTFyopJoVil38GMKLtUXU&e=" rel="noreferrer" target="_blank">float32.gt</a>: greater than<br>
>   * <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__float32.ge&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=p6AgDrp7Et72GfhcUaiXPpvrsDDHNlBTfR5z4j0YweY&s=blppmuP9BaMsWQD_R74G0cZ1X6r9iGrLSGgrIQjzMBQ&e=" rel="noreferrer" target="_blank">float32.ge</a>: greater than or equal<br>
> - * float32.sqrt: square root<br>
> + */<br>
> +<br>
> +defm SQRT : UnaryFP<fsqrt>;<br>
> +<br>
> +/*<br>
> + * TODO(jfb): Add the following for 32-bit and 64-bit.<br>
> + *<br>
>   * float32.min: minimum (binary operator); if either operand is NaN, returns NaN<br>
>   * float32.max: maximum (binary operator); if either operand is NaN, returns NaN<br>
>   */<br>
><br>
> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFormats.td<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Target_WebAssembly_WebAssemblyInstrFormats.td-3Frev-3D242201-26r1-3D242200-26r2-3D242201-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=p6AgDrp7Et72GfhcUaiXPpvrsDDHNlBTfR5z4j0YweY&s=UlJw2XzDBUwLmrofVba9jtunGz63MFTn9kHLDFvMLfg&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFormats.td?rev=242201&r1=242200&r2=242201&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFormats.td (original)<br>
> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrFormats.td Tue Jul 14 16:13:29 2015<br>
> @@ -27,3 +27,29 @@ class I<dag oops, dag iops, list<dag> pa<br>
>    dag InOperandList  = iops;<br>
>    let Pattern        = pattern;<br>
>  }<br>
> +<br>
> +// Unary and binary instructions, for the local types that WebAssembly supports.<br>
> +multiclass UnaryInt<SDNode node> {<br>
> +  def _I32 : I<(outs Int32:$dst), (ins Int32:$src),<br>
> +               [(set Int32:$dst, (node Int32:$src))]>;<br>
> +  def _I64 : I<(outs Int64:$dst), (ins Int64:$src),<br>
> +               [(set Int64:$dst, (node Int64:$src))]>;<br>
> +}<br>
> +multiclass BinaryInt<SDNode node> {<br>
> +  def _I32 : I<(outs Int32:$dst), (ins Int32:$lhs, Int32:$rhs),<br>
> +               [(set Int32:$dst, (node Int32:$lhs, Int32:$rhs))]>;<br>
> +  def _I64 : I<(outs Int64:$dst), (ins Int64:$lhs, Int64:$rhs),<br>
> +               [(set Int64:$dst, (node Int64:$lhs, Int64:$rhs))]>;<br>
> +}<br>
> +multiclass UnaryFP<SDNode node> {<br>
> +  def _F32 : I<(outs Float32:$dst), (ins Float32:$src),<br>
> +               [(set Float32:$dst, (node Float32:$src))]>;<br>
> +  def _F64 : I<(outs Float64:$dst), (ins Float64:$src),<br>
> +               [(set Float64:$dst, (node Float64:$src))]>;<br>
> +}<br>
> +multiclass BinaryFP<SDNode node> {<br>
> +  def _F32 : I<(outs Float32:$dst), (ins Float32:$lhs, Float32:$rhs),<br>
> +               [(set Float32:$dst, (node Float32:$lhs, Float32:$rhs))]>;<br>
> +  def _F64 : I<(outs Float64:$dst), (ins Float64:$lhs, Float64:$rhs),<br>
> +               [(set Float64:$dst, (node Float64:$lhs, Float64:$rhs))]>;<br>
> +}<br>
><br>
> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Target_WebAssembly_WebAssemblyInstrInteger.td-3Frev-3D242201-26r1-3D242200-26r2-3D242201-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=p6AgDrp7Et72GfhcUaiXPpvrsDDHNlBTfR5z4j0YweY&s=eiaoI55ctsl8AiqY6Eocduh4mH2w83pef9fzny_8954&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td?rev=242201&r1=242200&r2=242201&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td (original)<br>
> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td Tue Jul 14 16:13:29 2015<br>
> @@ -12,22 +12,23 @@<br>
>  ///<br>
>  //===----------------------------------------------------------------------===//<br>
><br>
> +defm ADD : BinaryInt<add>;<br>
> +defm SUB : BinaryInt<sub>;<br>
> +defm MUL : BinaryInt<mul>;<br>
> +defm SDIV : BinaryInt<sdiv>;<br>
> +defm UDIV : BinaryInt<udiv>;<br>
> +defm SREM : BinaryInt<srem>;<br>
> +defm UREM : BinaryInt<urem>;<br>
> +defm AND : BinaryInt<and>;<br>
> +defm IOR : BinaryInt<or>;<br>
> +defm XOR : BinaryInt<xor>;<br>
> +defm SHL : BinaryInt<shl>;<br>
> +defm SHR : BinaryInt<srl>;<br>
> +defm SAR : BinaryInt<sra>;<br>
> +<br>
>  /*<br>
>   * TODO(jfb): Add the following for 32-bit and 64-bit.<br>
>   *<br>
> - * int32.add: signed-less addition<br>
> - * int32.sub: signed-less subtraction<br>
> - * int32.mul: signed-less multiplication (lower 32-bits)<br>
> - * int32.sdiv: signed division<br>
> - * int32.udiv: unsigned division<br>
> - * int32.srem: signed remainder<br>
> - * int32.urem: unsigned remainder<br>
> - * int32.and: signed-less logical and<br>
> - * int32.ior: signed-less inclusive or<br>
> - * int32.xor: signed-less exclusive or<br>
> - * int32.shl: signed-less shift left<br>
> - * int32.shr: signed-less logical shift right<br>
> - * int32.sar: signed-less arithmetic shift right<br>
>   * int32.eq: signed-less compare equal<br>
>   * int32.slt: signed less than<br>
>   * int32.sle: signed less than or equal<br>
> @@ -37,7 +38,8 @@<br>
>   * int32.sge: signed greater than or equal<br>
>   * int32.ugt: unsigned greater than<br>
>   * int32.uge: unsigned greater than or equal<br>
> - * int32.clz: count leading zeroes (defined for all values, including zero)<br>
> - * int32.ctz: count trailing zeroes (defined for all values, including zero)<br>
> - * int32.popcnt: count number of ones<br>
>   */<br>
> +<br>
> +defm CLZ : UnaryInt<ctlz>;<br>
> +defm CTZ : UnaryInt<cttz>;<br>
> +defm POPCNT : UnaryInt<ctpop>;<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>