qemu/tests/tcg/openrisc/test_lf_lts.c
<<
>>
Prefs
   1#include <stdio.h>
   2
   3int main(void)
   4{
   5    int a;
   6    float b, c, d;
   7    int result;
   8
   9    a = 0;
  10    b = 124.5;
  11    c = 1.4;
  12    result = 1;
  13    __asm
  14    ("lfltd:\n\t"
  15     "l.addi    %0, %0, 0x1\n\t"
  16     "lf.sflt.s %1, %2\n\t"
  17     "l.bf      lfltd\n\t"
  18     "l.nop\n\t"
  19     : "+r"(a)
  20     : "r"(b), "r"(c)
  21    );
  22    if (a != result) {
  23        printf("lf.sflt.s error\n");
  24        return -1;
  25    }
  26
  27    a = 0;
  28    b = 11.1;
  29    c = 13.1;
  30    d = 1.0;
  31    result = 2;
  32    __asm
  33    ("1:\n\t"
  34     "lf.add.s  %1, %1, %3\n\t"
  35     "l.addi    %0, %0, 1\n\t"
  36     "lf.sflt.s %1, %2\n\t"
  37     "l.bf      1b\n\t"
  38     "l.nop\n\t"
  39     : "+r"(a)
  40     : "r"(b), "r"(c), "r"(d)
  41    );
  42    if (a != result) {
  43        printf("lf.sflt.s error\n");
  44        return -1;
  45    }
  46
  47/*    int a;
  48    double b, c;
  49    int result;
  50
  51    a = 0;
  52    b = 1432.1;
  53    c = 2.4;
  54    result = 0x1;
  55    __asm
  56    ("lfltd:\n\t"
  57     "l.addi    %0, %0, 0x1\n\t"
  58     "lf.sflt.d %1, %2\n\t"
  59     "l.bf      lfltd\n\t"
  60     "l.nop\n\t"
  61     : "+r"(a)
  62     : "r"(b), "r"(c)
  63    );
  64    if (a != result) {
  65        printf("lf.sflt.d error\n");
  66        return -1;
  67    }
  68
  69    a = 0;
  70    b = 1.1;
  71    c = 19.7;
  72    result = 2;
  73    __asm
  74    ("lf.sflt.d %1, %2\n\t"
  75     "l.bf      1f\n\t"
  76     "l.nop\n\t"
  77     "l.addi %0, %0, 1\n\t"
  78     "l.addi %0, %0, 1\n\t"
  79     "l.addi %0, %0, 1\n\t"
  80     "1:\n\t"
  81     "l.addi %0, %0, 1\n\t"
  82     "l.addi %0, %0, 1\n\t"
  83     : "+r"(a), "+r"(b)
  84     : "r"(c)
  85    );
  86    if (a != result) {
  87        printf("lf.sflt.d error\n");
  88        return -1;
  89    }*/
  90
  91    return 0;
  92}
  93