llvm.org GIT mirror llvm / 523219b
[WebAssembly] Add the signature for the new llround builtin function r360889 added new llround builtin functions. This patch adds their signatures for the WebAssembly backend. It also adds wasm32 support to utils/update_llc_test_checks.py, since that's the script other targets are using for their testcases for this feature. Differential Revision: https://reviews.llvm.org/D62207 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361327 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 1 year, 6 months ago
3 changed file(s) with 70 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
8585 func_iPTR_i64_i64_i64_i64_i64_i64,
8686 i32_func_i64_i64,
8787 i32_func_i64_i64_i64_i64,
88 iPTR_func_f32,
89 iPTR_func_f64,
90 iPTR_func_i64_i64,
8891 unsupported
8992 };
9093
215218 Table[RTLIB::ROUND_F32] = f32_func_f32;
216219 Table[RTLIB::ROUND_F64] = f64_func_f64;
217220 Table[RTLIB::ROUND_F128] = func_iPTR_i64_i64;
221 Table[RTLIB::LROUND_F32] = iPTR_func_f32;
222 Table[RTLIB::LROUND_F64] = iPTR_func_f64;
223 Table[RTLIB::LROUND_F128] = iPTR_func_i64_i64;
224 Table[RTLIB::LLROUND_F32] = i64_func_f32;
225 Table[RTLIB::LLROUND_F64] = i64_func_f64;
226 Table[RTLIB::LLROUND_F128] = i64_func_i64_i64;
218227 Table[RTLIB::FLOOR_F32] = f32_func_f32;
219228 Table[RTLIB::FLOOR_F64] = f64_func_f64;
220229 Table[RTLIB::FLOOR_F128] = func_iPTR_i64_i64;
842851 Params.push_back(wasm::ValType::I64);
843852 Params.push_back(wasm::ValType::I64);
844853 break;
854 case iPTR_func_f32:
855 Rets.push_back(PtrTy);
856 Params.push_back(wasm::ValType::F32);
857 break;
858 case iPTR_func_f64:
859 Rets.push_back(PtrTy);
860 Params.push_back(wasm::ValType::F64);
861 break;
862 case iPTR_func_i64_i64:
863 Rets.push_back(PtrTy);
864 Params.push_back(wasm::ValType::I64);
865 Params.push_back(wasm::ValType::I64);
866 break;
845867 case unsupported:
846868 llvm_unreachable("unsupported runtime library signature");
847869 }
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc < %s -mtriple=wasm32 | FileCheck %s
2
3 define i64 @testmsxs_builtin(float %x) {
4 ; CHECK-LABEL: testmsxs_builtin:
5 ; CHECK: .functype testmsxs_builtin (f32) -> (i64)
6 ; CHECK-NEXT: # %bb.0: # %entry
7 ; CHECK-NEXT: local.get 0
8 ; CHECK-NEXT: i64.call llroundf
9 ; CHECK-NEXT: # fallthrough-return-value
10 ; CHECK-NEXT: end_function
11 entry:
12 %0 = tail call i64 @llvm.llround.f32(float %x)
13 ret i64 %0
14 }
15
16 define i64 @testmsxd_builtin(double %x) {
17 ; CHECK-LABEL: testmsxd_builtin:
18 ; CHECK: .functype testmsxd_builtin (f64) -> (i64)
19 ; CHECK-NEXT: # %bb.0: # %entry
20 ; CHECK-NEXT: local.get 0
21 ; CHECK-NEXT: i64.call llround
22 ; CHECK-NEXT: # fallthrough-return-value
23 ; CHECK-NEXT: end_function
24 entry:
25 %0 = tail call i64 @llvm.llround.f64(double %x)
26 ret i64 %0
27 }
28
29 declare i64 @llvm.llround.f32(float) nounwind readnone
30 declare i64 @llvm.llround.f64(double) nounwind readnone
7777 ASM_FUNCTION_SYSTEMZ_RE = re.compile(
7878 r'^_?(?P[^:]+):[ \t]*#+[ \t]*@(?P=func)\n'
7979 r'[ \t]+.cfi_startproc\n'
80 r'(?P.*?)\n'
81 r'.Lfunc_end[0-9]+:\n',
82 flags=(re.M | re.S))
83
84 ASM_FUNCTION_WASM32_RE = re.compile(
85 r'^_?(?P[^:]+):[ \t]*#+[ \t]*@(?P=func)\n'
8086 r'(?P.*?)\n'
8187 r'.Lfunc_end[0-9]+:\n',
8288 flags=(re.M | re.S))
190196 return asm
191197
192198 def scrub_asm_systemz(asm, args):
199 # Scrub runs of whitespace out of the assembly, but leave the leading
200 # whitespace in place.
201 asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
202 # Expand the tabs used for indentation.
203 asm = string.expandtabs(asm, 2)
204 # Strip trailing whitespace.
205 asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
206 return asm
207
208 def scrub_asm_wasm32(asm, args):
193209 # Scrub runs of whitespace out of the assembly, but leave the leading
194210 # whitespace in place.
195211 asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
249265 'sparc': (scrub_asm_sparc, ASM_FUNCTION_SPARC_RE),
250266 'sparcv9': (scrub_asm_sparc, ASM_FUNCTION_SPARC_RE),
251267 's390x': (scrub_asm_systemz, ASM_FUNCTION_SYSTEMZ_RE),
268 'wasm32': (scrub_asm_wasm32, ASM_FUNCTION_WASM32_RE),
252269 }
253270 handlers = None
254271 for prefix, s in target_handlers.items():