diff mc-code-powerpc.c @ 616:2ba903c8e749

builtin_fabs builtin_inf()
author kono
date Wed, 06 Sep 2006 20:58:03 +0900
parents 2dee957ef988
children 72c4a8137fff
line wrap: on
line diff
--- a/mc-code-powerpc.c	Wed Sep 06 15:21:06 2006 +0900
+++ b/mc-code-powerpc.c	Wed Sep 06 20:58:03 2006 +0900
@@ -43,6 +43,9 @@
 #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
 #define __builtin_va_arg(ap,type)  (*((type *)ap)++)\n\
 #define alloca __builtin_alloca\n\
+#define    __FLT_MIN__  1.17549435e-38F\n\
+#define    __DBL_MIN__ 2.2250738585072014e-308\n\
+#define    __LDBL_MIN__ 2.00416836000897277799610805135016e-292L\n\
 ";
 
 #define TEXT_EMIT_MODE 0
@@ -1327,7 +1330,6 @@
     }
 }
 
-
 void
 code_neg(int creg) {
     use_int(creg);
@@ -3455,7 +3457,6 @@
 }
 
 void
-
 code_dconst(int e2,int freg,int d)
 { 
     int lb;
@@ -3508,6 +3509,78 @@
     free_register(r);
 }
 
+void
+code_builtin_fabsf(int e)
+{
+    char *frn;
+    g_expr0(e);
+    use_float(0,freg);
+    frn = fregister_name(freg);
+    printf("\tfabs %s,%s\n",frn,frn);
+}
+
+void
+code_builtin_fabs(int e)
+{
+    char *frn;
+    g_expr0(e);
+    use_float(1,freg);
+    frn = fregister_name(freg);
+    printf("\tfabs %s,%s\n",frn,frn);
+}
+
+static void
+code_inf(int d)
+{
+    int lb;
+    int r;
+    char *rrn,*frn;
+    int freg = USE_CREG;
+
+    use_float(d,freg);
+    frn = fregister_name(freg);
+    rrn = register_name((r=get_register()));
+    use_reg(r); // to clear ptr cache
+    printf(" \t.data\n\t.align 3\n");
+    lb=fwdlabel();
+    printf("L_%d:\n",lb);
+    if (d) {
+#if ENDIAN_D==0
+	printf("\t.long\t0x%x,0x%x\n",0,0x7ff00000);
+#else
+	printf("\t.long\t0x%x,0x%x\n",0x7ff00000,0);
+#endif
+    } else {
+	printf("\t.long\t0x%x\n",0x7f800000);
+    }
+    if (output_mode==TEXT_EMIT_MODE) {
+	printf(".text\n");
+    } else {
+	text_mode(0);
+    }
+    printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",rrn,lb,code_base);
+    printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",rrn,lb,code_base,rrn);
+    if (d) {
+	printf("\tlfd %s,0(%s)\n",frn,rrn);
+    } else {
+	printf("\tlfs %s,0(%s)\n",frn,rrn);
+    }
+    free_register(r);
+}
+
+void
+code_builtin_inff()
+{
+    code_inf(0);
+}
+
+void
+code_builtin_inf()
+{
+    code_inf(1);
+}
+
+
 
 void
 code_dneg(int freg,int d)