From 1fe3ed0e67d96fabcb26ac306fe34e7d5ea3102c Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Tue, 29 Jun 2010 01:33:09 +0000 Subject: [PATCH] Refactoring of arithmetic instruction classes with unary operator llvm-svn: 107116 --- lib/Target/X86/X86InstrSSE.td | 178 ++++++++++++---------------------- 1 file changed, 60 insertions(+), 118 deletions(-) diff --git a/lib/Target/X86/X86InstrSSE.td b/lib/Target/X86/X86InstrSSE.td index 8c0a84f4260..0ee1216fd2a 100644 --- a/lib/Target/X86/X86InstrSSE.td +++ b/lib/Target/X86/X86InstrSSE.td @@ -1863,82 +1863,95 @@ let isCommutable = 0 in { defm MIN : sse12_fp_binop_rm<0x5D, "min", X86fmin>; } -// Arithmetic - -/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms. -/// +/// Unop Arithmetic /// In addition, we also have a special variant of the scalar form here to /// represent the associated intrinsic operation. This form is unlike the /// plain scalar form, in that it takes an entire vector (instead of a /// scalar) and leaves the top elements undefined. /// /// And, we have a special variant form for a full-vector intrinsic form. -/// -multiclass sse1_fp_unop_rm opc, string OpcodeStr, - SDNode OpNode, - Intrinsic F32Int, - Intrinsic V4F32Int, - bit Commutable = 0> { - // Scalar operation, reg. + +/// sse1_fp_unop_s - SSE1 unops in scalar form. +multiclass sse1_fp_unop_s opc, string OpcodeStr, + SDNode OpNode, Intrinsic F32Int> { def SSr : SSI { - let isCommutable = Commutable; - } - - // Scalar operation, mem. + [(set FR32:$dst, (OpNode FR32:$src))]>; def SSm : I, XS, Requires<[HasSSE1, OptForSize]>; - - // Vector operation, reg. - def PSr : PSI { - let isCommutable = Commutable; - } - - // Vector operation, mem. - def PSm : PSI; - - // Intrinsic operation, reg. def SSr_Int : SSI { - let isCommutable = Commutable; - } - - // Intrinsic operation, mem. + [(set VR128:$dst, (F32Int VR128:$src))]>; def SSm_Int : SSI; +} - // Vector intrinsic operation, reg +/// sse1_fp_unop_p - SSE1 unops in scalar form. +multiclass sse1_fp_unop_p opc, string OpcodeStr, + SDNode OpNode, Intrinsic V4F32Int> { + def PSr : PSI; + def PSm : PSI; def PSr_Int : PSI { - let isCommutable = Commutable; - } - - // Vector intrinsic operation, mem + [(set VR128:$dst, (V4F32Int VR128:$src))]>; def PSm_Int : PSI; } +/// sse2_fp_unop_s - SSE2 unops in scalar form. +multiclass sse2_fp_unop_s opc, string OpcodeStr, + SDNode OpNode, Intrinsic F64Int> { + def SDr : SDI; + def SDm : SDI; + def SDr_Int : SDI; + def SDm_Int : SDI; +} + +/// sse2_fp_unop_p - SSE2 unops in vector forms. +multiclass sse2_fp_unop_p opc, string OpcodeStr, + SDNode OpNode, Intrinsic V2F64Int> { + def PDr : PDI; + def PDm : PDI; + def PDr_Int : PDI; + def PDm_Int : PDI; +} + // Square root. -defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt, - int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>; +defm SQRT : sse1_fp_unop_s<0x51, "sqrt", fsqrt, int_x86_sse_sqrt_ss>, + sse1_fp_unop_p<0x51, "sqrt", fsqrt, int_x86_sse_sqrt_ps>, + sse2_fp_unop_s<0x51, "sqrt", fsqrt, int_x86_sse2_sqrt_sd>, + sse2_fp_unop_p<0x51, "sqrt", fsqrt, int_x86_sse2_sqrt_pd>; // Reciprocal approximations. Note that these typically require refinement // in order to obtain suitable precision. -defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt, - int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>; -defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp, - int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>; +defm RSQRT : sse1_fp_unop_s<0x52, "rsqrt", X86frsqrt, int_x86_sse_rsqrt_ss>, + sse1_fp_unop_p<0x52, "rsqrt", X86frsqrt, int_x86_sse_rsqrt_ps>; +defm RCP : sse1_fp_unop_s<0x53, "rcp", X86frcp, int_x86_sse_rcp_ss>, + sse1_fp_unop_p<0x53, "rcp", X86frcp, int_x86_sse_rcp_ps>; // Prefetch intrinsic. def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), @@ -2011,77 +2024,6 @@ def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))), // SSE2 Instructions //===---------------------------------------------------------------------===// -// Arithmetic - -/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms. -/// -/// In addition, we also have a special variant of the scalar form here to -/// represent the associated intrinsic operation. This form is unlike the -/// plain scalar form, in that it takes an entire vector (instead of a -/// scalar) and leaves the top elements undefined. -/// -/// And, we have a special variant form for a full-vector intrinsic form. -/// -/// These four forms can each have a reg or a mem operand, so there are a -/// total of eight "instructions". -/// -multiclass sse2_fp_unop_rm opc, string OpcodeStr, - SDNode OpNode, - Intrinsic F64Int, - Intrinsic V2F64Int, - bit Commutable = 0> { - // Scalar operation, reg. - def SDr : SDI { - let isCommutable = Commutable; - } - - // Scalar operation, mem. - def SDm : SDI; - - // Vector operation, reg. - def PDr : PDI { - let isCommutable = Commutable; - } - - // Vector operation, mem. - def PDm : PDI; - - // Intrinsic operation, reg. - def SDr_Int : SDI { - let isCommutable = Commutable; - } - - // Intrinsic operation, mem. - def SDm_Int : SDI; - - // Vector intrinsic operation, reg - def PDr_Int : PDI { - let isCommutable = Commutable; - } - - // Vector intrinsic operation, mem - def PDm_Int : PDI; -} - -// Square root. -defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt, - int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>; // There is no f64 version of the reciprocal approximation instructions.