From da75127cea9dd7c29a681c883fa4036e32e9b560 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 7 Oct 2006 20:55:57 +0000 Subject: [PATCH] one multiclass now defines all 8 variants of binary-scalar-sse-fp operations. llvm-svn: 30814 --- lib/Target/X86/X86InstrSSE.td | 115 +++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/lib/Target/X86/X86InstrSSE.td b/lib/Target/X86/X86InstrSSE.td index d3b6c9672a5..24f54fab724 100644 --- a/lib/Target/X86/X86InstrSSE.td +++ b/lib/Target/X86/X86InstrSSE.td @@ -199,23 +199,6 @@ multiclass SD_IntUnary o, string OpcodeStr, Intrinsic IntId> { [(set VR128:$dst, (v2f64 (IntId (load addr:$src))))]>; } -class SS_Intrr o, string OpcodeStr, Intrinsic IntId> - : SSI; -class SS_Intrm o, string OpcodeStr, Intrinsic IntId> - : SSI; -class SD_Intrr o, string OpcodeStr, Intrinsic IntId> - : SDI; -class SD_Intrm o, string OpcodeStr, Intrinsic IntId> - : SDI; - class PS_Intr o, string OpcodeStr, Intrinsic IntId> : PSI; let isTwoAddress = 1 in { -/// scalar_sse12_fp_binop_rm - Define 4 scalar sse instructions. + +/// scalar_sse12_fp_binop_rm - Scalar SSE binops come in four basic forms: +/// 1. f32 vs f64 - These come in SSE1/SSE2 forms for float/doubles. +/// 2. rr vs rm - They include a reg+reg form and a ref+mem form. +/// +/// In addition, scalar SSE ops have an intrinsic form. This form is unlike the +/// normal form, in that they take an entire vector (instead of a scalar) and +/// leave the top elements undefined. This adds another two variants of the +/// above permutations, giving us 8 forms for 'instruction'. +/// multiclass scalar_sse12_fp_binop_rm opc, string OpcodeStr, - SDNode OpNode, bit Commutable = 0> { + SDNode OpNode, Intrinsic F32Int, + Intrinsic F64Int, bit Commutable = 0> { + // Scalar operation, reg+reg. def SSrr : SSI { @@ -319,21 +313,47 @@ multiclass scalar_sse12_fp_binop_rm opc, string OpcodeStr, [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> { let isCommutable = Commutable; } + // Scalar operation, reg+mem. def SSrm : SSI; def SDrm : SDI; + + // Vector intrinsic operation, reg+reg. + def SSrr_Int : SSI { + let isCommutable = Commutable; + } + def SDrr_Int : SDI { + let isCommutable = Commutable; + } + // Vector intrinsic operation, reg+mem. + def SSrm_Int : SSI; + def SDrm_Int : SDI; } } // Arithmetic instructions -defm ADD : scalar_sse12_fp_binop_rm<0x58, "add", fadd, 1>; -defm MUL : scalar_sse12_fp_binop_rm<0x59, "mul", fmul, 1>; -defm DIV : scalar_sse12_fp_binop_rm<0x5E, "div", fdiv>; -defm SUB : scalar_sse12_fp_binop_rm<0x5C, "sub", fsub>; +defm ADD : scalar_sse12_fp_binop_rm<0x58, "add", fadd, + int_x86_sse_add_ss, int_x86_sse2_add_sd, 1>; +defm MUL : scalar_sse12_fp_binop_rm<0x59, "mul", fmul, + int_x86_sse_mul_ss, int_x86_sse2_mul_sd, 1>; +defm SUB : scalar_sse12_fp_binop_rm<0x5C, "sub", fsub, + int_x86_sse_sub_ss, int_x86_sse2_sub_sd>; +defm DIV : scalar_sse12_fp_binop_rm<0x5E, "div", fdiv, + int_x86_sse_div_ss, int_x86_sse2_div_sd>; def SQRTSSr : SSI<0x51, MRMSrcReg, (ops FR32:$dst, FR32:$src), @@ -349,35 +369,30 @@ def SQRTSDm : SDI<0x51, MRMSrcMem, (ops FR64:$dst, f64mem:$src), "sqrtsd {$src, $dst|$dst, $src}", [(set FR64:$dst, (fsqrt (loadf64 addr:$src)))]>; +class SS_Intrr o, string OpcodeStr, Intrinsic IntId> + : SSI; +class SS_Intrm o, string OpcodeStr, Intrinsic IntId> + : SSI; +class SD_Intrr o, string OpcodeStr, Intrinsic IntId> + : SDI; +class SD_Intrm o, string OpcodeStr, Intrinsic IntId> + : SDI; + + // Aliases to match intrinsics which expect XMM operand(s). -let isTwoAddress = 1 in { -let isCommutable = 1 in { -def Int_ADDSSrr : SS_Intrr<0x58, "addss", int_x86_sse_add_ss>; -def Int_ADDSDrr : SD_Intrr<0x58, "addsd", int_x86_sse2_add_sd>; -def Int_MULSSrr : SS_Intrr<0x59, "mulss", int_x86_sse_mul_ss>; -def Int_MULSDrr : SD_Intrr<0x59, "mulsd", int_x86_sse2_mul_sd>; -} -def Int_ADDSSrm : SS_Intrm<0x58, "addss", int_x86_sse_add_ss>; -def Int_ADDSDrm : SD_Intrm<0x58, "addsd", int_x86_sse2_add_sd>; -def Int_MULSSrm : SS_Intrm<0x59, "mulss", int_x86_sse_mul_ss>; -def Int_MULSDrm : SD_Intrm<0x59, "mulsd", int_x86_sse2_mul_sd>; - -def Int_DIVSSrr : SS_Intrr<0x5E, "divss", int_x86_sse_div_ss>; -def Int_DIVSSrm : SS_Intrm<0x5E, "divss", int_x86_sse_div_ss>; -def Int_DIVSDrr : SD_Intrr<0x5E, "divsd", int_x86_sse2_div_sd>; -def Int_DIVSDrm : SD_Intrm<0x5E, "divsd", int_x86_sse2_div_sd>; - -def Int_SUBSSrr : SS_Intrr<0x5C, "subss", int_x86_sse_sub_ss>; -def Int_SUBSSrm : SS_Intrm<0x5C, "subss", int_x86_sse_sub_ss>; -def Int_SUBSDrr : SD_Intrr<0x5C, "subsd", int_x86_sse2_sub_sd>; -def Int_SUBSDrm : SD_Intrm<0x5C, "subsd", int_x86_sse2_sub_sd>; -} - -defm Int_SQRTSS : SS_IntUnary<0x51, "sqrtss" , int_x86_sse_sqrt_ss>; -defm Int_SQRTSD : SD_IntUnary<0x51, "sqrtsd" , int_x86_sse2_sqrt_sd>; -defm Int_RSQRTSS : SS_IntUnary<0x52, "rsqrtss", int_x86_sse_rsqrt_ss>; -defm Int_RCPSS : SS_IntUnary<0x53, "rcpss" , int_x86_sse_rcp_ss>; +defm SQRTSS_Int : SS_IntUnary<0x51, "sqrtss" , int_x86_sse_sqrt_ss>; +defm SQRTSD_Int : SD_IntUnary<0x51, "sqrtsd" , int_x86_sse2_sqrt_sd>; +defm RSQRTSS_Int : SS_IntUnary<0x52, "rsqrtss", int_x86_sse_rsqrt_ss>; +defm RCPSS_Int : SS_IntUnary<0x53, "rcpss" , int_x86_sse_rcp_ss>; let isTwoAddress = 1 in { let isCommutable = 1 in {