Home | History | Annotate | Download | only in s390x
      1 #include <stdio.h>
      2 
      3 /* Test BFP multiply and add/sub  32/64-bit. There are no such insns
      4    working with 128-bit data */
      5 
      6 void maebr(float v1, float v2, float v3)
      7 {
      8    float r1 = v1;
      9 
     10    __asm__ volatile("maebr %[r1],%[r3],%[r2]"
     11                     : [r1]"+f"(r1) : [r2]"f"(v2), [r3]"f"(v3));
     12    printf("maebr  %f * %f + %f  -> %f\n", v2, v3, v1, r1);
     13 }
     14 
     15 void madbr(double v1, double v2, double v3)
     16 {
     17    double r1 = v1;
     18 
     19    __asm__ volatile("madbr %[r1],%[r3],%[r2]"
     20                     : [r1]"+f"(r1) : [r2]"f"(v2), [r3]"f"(v3));
     21    printf("madbr  %f * %f + %f  -> %f\n", v2, v3, v1, r1);
     22 }
     23 
     24 void msebr(float v1, float v2, float v3)
     25 {
     26    float r1 = v1;
     27 
     28    __asm__ volatile("msebr %[r1],%[r3],%[r2]"
     29                     : [r1]"+f"(r1) : [r2]"f"(v2), [r3]"f"(v3));
     30    printf("msebr  %f * %f - %f  -> %f\n", v2, v3, v1, r1);
     31 }
     32 
     33 void msdbr(double v1, double v2, double v3)
     34 {
     35    double r1 = v1;
     36 
     37    __asm__ volatile("msdbr %[r1],%[r3],%[r2]"
     38                     : [r1]"+f"(r1) : [r2]"f"(v2), [r3]"f"(v3));
     39    printf("msdbr  %f * %f - %f  -> %f\n", v2, v3, v1, r1);
     40 }
     41 
     42 int main(void)
     43 {
     44    // multiply and add
     45    maebr(10.5f, 20.25, 3.0);  // 4 byte values
     46    madbr(-10.5, 42.75, -2.0); // 8 byte values
     47 
     48    // multiply and sub
     49    msebr(10.5f, 20.25, 3.0);  // 4 byte values
     50    msdbr(-10.5, 42.75, -2.0); // 8 byte values
     51 
     52    return 0;
     53 }
     54