Paste: nasty code

Author: prunedtre
Mode: text
Date: Sat, 9 Apr 2011 23:13:33
Plain Text |

alias punpcklbw_indices = #"<i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23>";
alias punpckhbw_indices = #"<i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>";
alias punpcklwd_indices = #"<i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>";

alias palignr_0_indices = #"<i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>";
alias palignr_1_indices = #"<i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16>";
alias palignr_2_indices = #"<i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17>";
alias palignr_3_indices = #"<i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18>";
alias palignr_4_indices = #"<i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19>";
alias palignr_5_indices = #"<i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20>";
alias palignr_6_indices = #"<i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21>";
alias palignr_7_indices = #"<i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22>";
alias palignr_8_indices = #"<i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>";
alias palignr_9_indices = #"<i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24>";
alias palignr_10_indices = #"<i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25>";
alias palignr_11_indices = #"<i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26>";
alias palignr_12_indices = #"<i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27>";
alias palignr_13_indices = #"<i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28>";
alias palignr_14_indices = #"<i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29>";
alias palignr_15_indices = #"<i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30>";

[SHUFFLE] private x86_shuffle_llvm(a:Vec[Byte,16], b:Vec[Byte,16], static SHUFFLE) returned:Vec[Byte,16] __llvm__{
    %1 = load ${Vec[Byte,16]} * %a
    %2 = load ${Vec[Byte,16]} * %b
    %3 = shufflevector ${Vec[Byte,16]} %1, ${Vec[Byte,16]} %2, <16 x i32> ${SHUFFLE}
    store ${Vec[Byte,16]} %3, ${Vec[Byte,16]} * %returned
    ret i32 0
}

x86_palignr_0(a, b) = x86_shuffle_llvm(a, b, palignr_0_indices);
x86_palignr_1(a, b) = x86_shuffle_llvm(a, b, palignr_1_indices);
x86_palignr_2(a, b) = x86_shuffle_llvm(a, b, palignr_2_indices);
x86_palignr_3(a, b) = x86_shuffle_llvm(a, b, palignr_3_indices);
x86_palignr_4(a, b) = x86_shuffle_llvm(a, b, palignr_4_indices);
x86_palignr_5(a, b) = x86_shuffle_llvm(a, b, palignr_5_indices);
x86_palignr_6(a, b) = x86_shuffle_llvm(a, b, palignr_6_indices);
x86_palignr_7(a, b) = x86_shuffle_llvm(a, b, palignr_7_indices);
x86_palignr_8(a, b) = x86_shuffle_llvm(a, b, palignr_8_indices);
x86_palignr_9(a, b) = x86_shuffle_llvm(a, b, palignr_9_indices);
x86_palignr_10(a, b) = x86_shuffle_llvm(a, b, palignr_10_indices);
x86_palignr_11(a, b) = x86_shuffle_llvm(a, b, palignr_11_indices);
x86_palignr_12(a, b) = x86_shuffle_llvm(a, b, palignr_12_indices);
x86_palignr_13(a, b) = x86_shuffle_llvm(a, b, palignr_13_indices);
x86_palignr_14(a, b) = x86_shuffle_llvm(a, b, palignr_14_indices);
x86_palignr_15(a, b) = x86_shuffle_llvm(a, b, palignr_15_indices);

x86_palignr(a,b,c)
{
    if (c==0) return x86_palignr_0(a,b);
    if (c==1) return x86_palignr_1(a,b);
    if (c==2) return x86_palignr_2(a,b);
    if (c==3) return x86_palignr_3(a,b);
    if (c==4) return x86_palignr_4(a,b);
    if (c==5) return x86_palignr_5(a,b);
    if (c==6) return x86_palignr_6(a,b);
    if (c==7) return x86_palignr_7(a,b);
    if (c==8) return x86_palignr_8(a,b);
    if (c==9) return x86_palignr_9(a,b);
    if (c==10) return x86_palignr_10(a,b);
    if (c==11) return x86_palignr_11(a,b);
    if (c==12) return x86_palignr_12(a,b);
    if (c==13) return x86_palignr_13(a,b);
    if (c==14) return x86_palignr_14(a,b);
    if (c==15) return x86_palignr_15(a,b);
    
    breakpoint(); // this ain't good !
    return x86_palignr_0(a,b);
}

New Annotation

Summary:
Author:
Mode:
Body: