[go: up one dir, main page]

File: mkalias.c

package info (click to toggle)
sleef 3.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,436 kB
  • sloc: ansic: 45,429; sh: 239; java: 151; makefile: 130
file content (143 lines) | stat: -rw-r--r-- 4,751 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//   Copyright Naoki Shibata and contributors 2010 - 2020.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

#include "funcproto.h"

int main(int argc, char **argv) {
  if (argc == 2 && strcmp(argv[1], "0") == 0) exit(0);

  if (argc < 6) {
    fprintf(stderr, "Usage : %s <vector width> <vector FP type> <vector int type> <mangled ISA> <extension>\n", argv[0]);
    exit(-1);
  }

  int vw = atoi(argv[1]);
  int fptype = vw >= 0 ? 0 : 1;
  vw = vw < 0 ? -vw : vw;
  char *mangledisa = argv[4];
  char *isaname = argc == 6 ? argv[5] : "";

  char * vectorcc="";
#ifdef ENABLE_AAVPCS
  if (strcmp(isaname, "advsimd") == 0)
    vectorcc =" __attribute__((aarch64_vector_pcs))";
#endif

  static char *argType2[] = {
    "a0", "a0, a1", "a0", "a0, a1",
    "a0", "a0, a1, a2", "a0", "a0", "a0"
  };
  static char *typeSpecS[] = { "", "f" };
  static char *typeSpec[] = { "d", "f" };
  static char *ulpSuffixStr[] = { "", "_u1", "_u05", "_u35", "_u15", "_u3500" };
  static char *vparameterStr[7] = { "v", "vv", "", "vv", "v", "vvv", "" };

  static char returnType[9][1000];
  static char argType0[9][1000];
  static char argType1[9][1000];
  
  sprintf(returnType[0], "%s", argv[2]);
  sprintf(returnType[1], "%s", argv[2]);
  sprintf(returnType[2], "%s", fptype ? "vfloat2" : "vdouble2");
  sprintf(returnType[3], "%s", argv[2]);
  sprintf(returnType[4], "%s", argv[3]);
  sprintf(returnType[5], "%s", argv[2]);
  sprintf(returnType[6], "%s", fptype ? "vfloat2" : "vdouble2");
  sprintf(returnType[7], "int");
  sprintf(returnType[8], "void *");

  sprintf(argType0[0], "%s", argv[2]);
  sprintf(argType0[1], "%s, %s", argv[2], argv[2]);
  sprintf(argType0[2], "%s", argv[2]);
  sprintf(argType0[3], "%s, %s", argv[2], argv[3]);
  sprintf(argType0[4], "%s", argv[2]);
  sprintf(argType0[5], "%s, %s, %s", argv[2], argv[2], argv[2]);
  sprintf(argType0[6], "%s", argv[2]);
  sprintf(argType0[7], "int");
  sprintf(argType0[8], "int");

  sprintf(argType1[0], "%s a0", argv[2]);
  sprintf(argType1[1], "%s a0, %s a1", argv[2], argv[2]);
  sprintf(argType1[2], "%s a0", argv[2]);
  sprintf(argType1[3], "%s a0, %s a1", argv[2], argv[3]);
  sprintf(argType1[4], "%s a0", argv[2]);
  sprintf(argType1[5], "%s a0, %s a1, %s a2", argv[2], argv[2], argv[2]);
  sprintf(argType1[6], "%s a0", argv[2]);
  sprintf(argType1[7], "int a0");
  sprintf(argType1[8], "int a0");

  //

  if (fptype == 0) {
    printf("#ifdef __SLEEFSIMDDP_C__\n");
  } else {
    printf("#ifdef __SLEEFSIMDSP_C__\n");
  }
  printf("#ifdef ENABLE_ALIAS\n");

  if (argc == 6) {
    for(int i=0;funcList[i].name != NULL;i++) {
      if (fptype == 0 && (funcList[i].flags & 2) != 0) continue;
      if (funcList[i].ulp >= 0) {
	printf("EXPORT CONST %s Sleef_%s%s%d_u%02d(%s) __attribute__((alias(\"Sleef_%s%s%d_u%02d%s\"))) %s;\n",
	       returnType[funcList[i].funcType],
	       funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp,
	       argType0[funcList[i].funcType],
	       funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp, isaname, vectorcc
	       );
      } else {
	printf("EXPORT CONST %s Sleef_%s%s%d(%s) __attribute__((alias(\"Sleef_%s%s%d_%s\"))) %s;\n",
	       returnType[funcList[i].funcType],
	       funcList[i].name, typeSpec[fptype], vw,
	       argType0[funcList[i].funcType],
	       funcList[i].name, typeSpec[fptype], vw, isaname, vectorcc
	       );
      }
    }

    printf("\n");
  }
  
  printf("#else // #ifdef ENABLE_ALIAS\n");

  if (argc == 6) {
    for(int i=0;funcList[i].name != NULL;i++) {
      if (fptype == 0 && (funcList[i].flags & 2) != 0) continue;
      if (funcList[i].ulp >= 0) {
	printf("EXPORT CONST %s %s Sleef_%s%s%d_u%02d(%s) { return Sleef_%s%s%d_u%02d%s(%s); }\n",
	       returnType[funcList[i].funcType], vectorcc,
	       funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp,
	       argType1[funcList[i].funcType],
	       funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp, isaname,
	       argType2[funcList[i].funcType]
	       );
      } else {
	printf("EXPORT CONST %s %s Sleef_%s%s%d(%s) { return Sleef_%s%s%d_%s(%s); }\n",
	       returnType[funcList[i].funcType], vectorcc,
	       funcList[i].name, typeSpec[fptype], vw,
	       argType1[funcList[i].funcType],
	       funcList[i].name, typeSpec[fptype], vw, isaname,
	       argType2[funcList[i].funcType]
	       );
      }
    }

    printf("\n");
  }

  printf("#endif // #ifdef ENABLE_ALIAS\n");
  if (fptype == 0) {
    printf("#endif // #ifdef __SLEEFSIMDDP_C__\n");
  } else {
    printf("#endif // #ifdef __SLEEFSIMDSP_C__\n");
  }

  exit(0);
}