Commit b85cde16 by Srdjan Obucina Committed by Jim Stichnoth

Subzero, MIPS32: Introduction of genTargetHelperCallFor

genTargetHelperCallFor provides framework for calling Subzero runtime functions. This patch implements calls and tests for some of the available functions, but not all. Current lowerCall implementation does not allow more (Handling of FP return values is missing). R=stichnot@chromium.org Review URL: https://codereview.chromium.org/2317653004 . Patch from Srdjan Obucina <srdjan.obucina@imgtec.com>.
parent 84ea9a70
......@@ -565,7 +565,7 @@ protected:
(void)Instr;
return 0;
}
void genTargetHelperCallFor(Inst *Instr) override { (void)Instr; }
void genTargetHelperCallFor(Inst *Instr) override;
void doAddressOptLoad() override;
void doAddressOptStore() override;
void randomlyInsertNop(float Probability,
......
......@@ -408,6 +408,9 @@ entry:
; ARM32: bne
; ARM32: bl {{.*}} __divdi3
; MIPS32-LABEL: div64BitSigned
; MIPS32: jal {{.*}} __divdi3
define internal i64 @div64BitSignedConst(i64 %a) {
entry:
%div = sdiv i64 %a, 12345678901234
......@@ -431,6 +434,9 @@ entry:
; ARM32: movw {{.*}} ; 0xb3a
; ARM32: bl {{.*}} __divdi3
; MIPS32-LABEL: div64BitSignedConst
; MIPS32: jal {{.*}} __divdi3
define internal i64 @div64BitUnsigned(i64 %a, i64 %b) {
entry:
%div = udiv i64 %a, %b
......@@ -447,6 +453,9 @@ entry:
; ARM32: bne
; ARM32: bl {{.*}} __udivdi3
; MIPS32-LABEL: div64BitUnsigned
; MIPS32: jal {{.*}} __udivdi3
define internal i64 @rem64BitSigned(i64 %a, i64 %b) {
entry:
%rem = srem i64 %a, %b
......@@ -463,6 +472,9 @@ entry:
; ARM32: bne
; ARM32: bl {{.*}} __moddi3
; MIPS32-LABEL: rem64BitSigned
; MIPS32: jal {{.*}} __moddi3
define internal i64 @rem64BitUnsigned(i64 %a, i64 %b) {
entry:
%rem = urem i64 %a, %b
......@@ -479,6 +491,9 @@ entry:
; ARM32: bne
; ARM32: bl {{.*}} __umoddi3
; MIPS32-LABEL: rem64BitUnsigned
; MIPS32: jal {{.*}} __umoddi3
define internal i64 @shl64BitSigned(i64 %a, i64 %b) {
entry:
%shl = shl i64 %a, %b
......
......@@ -171,8 +171,7 @@ entry:
; ARM32HWDIV: sdiv
; MIPS32-LABEL: Sdiv
; MIPS32: div
; MIPS32: mflo
; MIPS32: jal {{.*}} __divsi3
define internal i32 @SdivConst(i32 %a) {
entry:
......@@ -191,8 +190,7 @@ entry:
; ARM32HWDIV: sdiv
; MIPS32-LABEL: SdivConst
; MIPS32: div
; MIPS32: mflo
; MIPS32: jal {{.*}} __divsi3
define internal i32 @Srem(i32 %a, i32 %b) {
entry:
......@@ -214,8 +212,7 @@ entry:
; ARM32HWDIV: mls
; MIPS32-LABEL: Srem
; MIPS32: div
; MIPS32: mfhi
; MIPS32: jal {{.*}} __modsi3
define internal i32 @Udiv(i32 %a, i32 %b) {
entry:
......@@ -235,8 +232,7 @@ entry:
; ARM32HWDIV: udiv
; MIPS32-LABEL: Udiv
; MIPS32: divu
; MIPS32: mflo
; MIPS32: jal {{.*}} __udivsi3
define internal i32 @Urem(i32 %a, i32 %b) {
entry:
......@@ -257,8 +253,7 @@ entry:
; ARM32HWDIV: mls
; MIPS32-LABEL: Urem
; MIPS32: divu
; MIPS32: mfhi
; MIPS32: jal {{.*}} __umodsi3
; The following tests check that shift instructions don't try to use a
; ConstantRelocatable as an immediate operand.
......
......@@ -145,6 +145,8 @@ entry:
; CHECK: call {{.*}} R_{{.*}} fmodf
; ARM32-LABEL: remFloat
; ARM32: bl {{.*}} fmodf
; MIPS32-LABEL: remFloat
; MIPS32: jal {{.*}} fmodf
define internal double @remDouble(double %a, double %b) {
entry:
......@@ -155,3 +157,5 @@ entry:
; CHECK: call {{.*}} R_{{.*}} fmod
; ARM32-LABEL: remDouble
; ARM32: bl {{.*}} fmod
; MIPS32-LABEL: remDouble
; MIPS32: jal {{.*}} fmod
......@@ -16,6 +16,12 @@
; RUN: | %if --need=target_ARM32 --need=allow_dump \
; RUN: --command FileCheck --check-prefix ARM32 %s
; RUN: %if --need=target_MIPS32 --need=allow_dump \
; RUN: --command %p2i --filetype=asm --assemble --disassemble --target mips32\
; RUN: -i %s --args -Om1 --skip-unimplemented \
; RUN: | %if --need=target_MIPS32 --need=allow_dump \
; RUN: --command FileCheck --check-prefix MIPS32 %s
declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1)
......@@ -34,6 +40,8 @@ entry:
; OM1: call {{.*}} memcpy
; ARM32-LABEL: test_memcpy
; ARM32: bl {{.*}} memcpy
; MIPS32-LABEL: test_memcpy
; MIPS32: jal {{.*}} memcpy
define internal void @test_memcpy_long_const_len(i32 %iptr_dst, i32 %iptr_src) {
entry:
......@@ -49,6 +57,8 @@ entry:
; OM1: call {{.*}} memcpy
; ARM32-LABEL: test_memcpy_long_const_len
; ARM32: bl {{.*}} memcpy
; MIPS32-LABEL: test_memcpy_long_const_len
; MIPS32: jal {{.*}} memcpy
define internal void @test_memcpy_very_small_const_len(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -67,6 +77,8 @@ entry:
; OM1: call {{.*}} memcpy
; ARM32-LABEL: test_memcpy_very_small_const_len
; ARM32: bl {{.*}} memcpy
; MIPS32-LABEL: test_memcpy_very_small_const_len
; MIPS32: jal {{.*}} memcpy
define internal void @test_memcpy_const_len_3(i32 %iptr_dst, i32 %iptr_src) {
entry:
......@@ -86,6 +98,8 @@ entry:
; OM1: call {{.*}} memcpy
; ARM32-LABEL: test_memcpy_const_len_3
; ARM32: bl {{.*}} memcpy
; MIPS32-LABEL: test_memcpy_const_len_3
; MIPS32: jal {{.*}} memcpy
define internal void @test_memcpy_mid_const_len(i32 %iptr_dst, i32 %iptr_src) {
entry:
......@@ -105,6 +119,8 @@ entry:
; OM1: call {{.*}} memcpy
; ARM32-LABEL: test_memcpy_mid_const_len
; ARM32: bl {{.*}} memcpy
; MIPS32-LABEL: test_memcpy_mid_const_len
; MIPS32: jal {{.*}} memcpy
define internal void @test_memcpy_mid_const_len_overlap(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -125,6 +141,8 @@ entry:
; OM1: call {{.*}} memcpy
; ARM32-LABEL: test_memcpy_mid_const_len_overlap
; ARM32: bl {{.*}} memcpy
; MIPS32-LABEL: test_memcpy_mid_const_len_overlap
; MIPS32: jal {{.*}} memcpy
define internal void @test_memcpy_big_const_len_overlap(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -145,6 +163,8 @@ entry:
; OM1: call {{.*}} memcpy
; ARM32-LABEL: test_memcpy_big_const_len_overlap
; ARM32: bl {{.*}} memcpy
; MIPS32-LABEL: test_memcpy_big_const_len_overlap
; MIPS32: jal {{.*}} memcpy
define internal void @test_memcpy_large_const_len(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -167,6 +187,8 @@ entry:
; OM1: call {{.*}} memcpy
; ARM32-LABEL: test_memcpy_large_const_len
; ARM32: bl {{.*}} memcpy
; MIPS32-LABEL: test_memcpy_large_const_len
; MIPS32: jal {{.*}} memcpy
define internal void @test_memmove(i32 %iptr_dst, i32 %iptr_src, i32 %len) {
entry:
......@@ -182,6 +204,8 @@ entry:
; OM1: call {{.*}} memmove
; ARM32-LABEL: test_memmove
; ARM32: bl {{.*}} memmove
; MIPS32-LABEL: test_memmove
; MIPS32: jal {{.*}} memmove
define internal void @test_memmove_long_const_len(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -198,6 +222,8 @@ entry:
; OM1: call {{.*}} memmove
; ARM32-LABEL: test_memmove_long_const_len
; ARM32: bl {{.*}} memmove
; MIPS32-LABEL: test_memmove_long_const_len
; MIPS32: jal {{.*}} memmove
define internal void @test_memmove_very_small_const_len(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -216,6 +242,8 @@ entry:
; OM1: call {{.*}} memmove
; ARM32-LABEL: test_memmove_very_small_const_len
; ARM32: bl {{.*}} memmove
; MIPS32-LABEL: test_memmove_very_small_const_len
; MIPS32: jal {{.*}} memmove
define internal void @test_memmove_const_len_3(i32 %iptr_dst, i32 %iptr_src) {
entry:
......@@ -235,6 +263,8 @@ entry:
; OM1: call {{.*}} memmove
; ARM32-LABEL: test_memmove_const_len_3
; ARM32: bl {{.*}} memmove
; MIPS32-LABEL: test_memmove_const_len_3
; MIPS32: jal {{.*}} memmove
define internal void @test_memmove_mid_const_len(i32 %iptr_dst, i32 %iptr_src) {
entry:
......@@ -254,6 +284,8 @@ entry:
; OM1: call {{.*}} memmove
; ARM32-LABEL: test_memmove_mid_const_len
; ARM32: bl {{.*}} memmove
; MIPS32-LABEL: test_memmove_mid_const_len
; MIPS32: jal {{.*}} memmove
define internal void @test_memmove_mid_const_len_overlap(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -274,6 +306,8 @@ entry:
; OM1: call {{.*}} memmove
; ARM32-LABEL: test_memmove_mid_const_len_overlap
; ARM32: bl {{.*}} memmove
; MIPS32-LABEL: test_memmove_mid_const_len_overlap
; MIPS32: jal {{.*}} memmove
define internal void @test_memmove_big_const_len_overlap(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -294,6 +328,8 @@ entry:
; OM1: call {{.*}} memmove
; ARM32-LABEL: test_memmove_big_const_len_overlap
; ARM32: bl {{.*}} memmove
; MIPS32-LABEL: test_memmove_big_const_len_overlap
; MIPS32: jal {{.*}} memmove
define internal void @test_memmove_large_const_len(i32 %iptr_dst,
i32 %iptr_src) {
......@@ -316,6 +352,8 @@ entry:
; OM1: call {{.*}} memmove
; ARM32-LABEL: test_memmove_large_const_len
; ARM32: bl {{.*}} memmove
; MIPS32-LABEL: test_memmove_large_const_len
; MIPS32: jal {{.*}} memmove
define internal void @test_memset(i32 %iptr_dst, i32 %wide_val, i32 %len) {
entry:
......@@ -334,6 +372,8 @@ entry:
; ARM32-LABEL: test_memset
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset
; MIPS32: jal {{.*}} memset
define internal void @test_memset_const_len_align(i32 %iptr_dst,
i32 %wide_val) {
......@@ -353,6 +393,8 @@ entry:
; ARM32-LABEL: test_memset_const_len_align
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_const_len_align
; MIPS32: jal {{.*}} memset
define internal void @test_memset_long_const_len_zero_val_align(
i32 %iptr_dst) {
......@@ -369,6 +411,8 @@ entry:
; ARM32-LABEL: test_memset_long_const_len_zero_val_align
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_long_const_len_zero_val_align
; MIPS32: jal {{.*}} memset
define internal void @test_memset_const_val(i32 %iptr_dst, i32 %len) {
entry:
......@@ -384,6 +428,8 @@ entry:
; ARM32-LABEL: test_memset_const_val
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_const_val
; MIPS32: jal {{.*}} memset
define internal void @test_memset_const_val_len_very_small(i32 %iptr_dst) {
entry:
......@@ -399,6 +445,8 @@ entry:
; ARM32-LABEL: test_memset_const_val_len_very_small
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_const_val_len_very_small
; MIPS32: jal {{.*}} memset
define internal void @test_memset_const_val_len_3(i32 %iptr_dst) {
entry:
......@@ -415,6 +463,8 @@ entry:
; ARM32-LABEL: test_memset_const_val_len_3
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_const_val_len_3
; MIPS32: jal {{.*}} memset
define internal void @test_memset_const_val_len_mid(i32 %iptr_dst) {
entry:
......@@ -432,6 +482,8 @@ entry:
; ARM32-LABEL: test_memset_const_val_len_mid
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_const_val_len_mid
; MIPS32: jal {{.*}} memset
; Same as above, but with a negative value.
define internal void @test_memset_const_neg_val_len_mid(i32 %iptr_dst) {
......@@ -450,6 +502,8 @@ entry:
; ARM32-LABEL: test_memset_const_neg_val_len_mid
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_const_neg_val_len_mid
; MIPS32: jal {{.*}} memset
define internal void @test_memset_zero_const_len_small(i32 %iptr_dst) {
entry:
......@@ -467,6 +521,8 @@ entry:
; ARM32-LABEL: test_memset_zero_const_len_small
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_zero_const_len_small
; MIPS32: jal {{.*}} memset
define internal void @test_memset_zero_const_len_small_overlap(i32 %iptr_dst) {
entry:
......@@ -484,6 +540,8 @@ entry:
; ARM32-LABEL: test_memset_zero_const_len_small_overlap
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_zero_const_len_small_overlap
; MIPS32: jal {{.*}} memset
define internal void @test_memset_zero_const_len_big_overlap(i32 %iptr_dst) {
entry:
......@@ -501,6 +559,8 @@ entry:
; ARM32-LABEL: test_memset_zero_const_len_big_overlap
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_zero_const_len_big_overlap
; MIPS32: jal {{.*}} memset
define internal void @test_memset_zero_const_len_large(i32 %iptr_dst) {
entry:
......@@ -519,3 +579,5 @@ entry:
; ARM32-LABEL: test_memset_zero_const_len_large
; ARM32: uxtb
; ARM32: bl {{.*}} memset
; MIPS32-LABEL: test_memset_zero_const_len_large
; MIPS32: jal {{.*}} memset
......@@ -34,6 +34,13 @@
; RUN: | %if --need=target_ARM32 --need=allow_dump \
; RUN: --command FileCheck --check-prefix ARM32 %s
; RUN: %if --need=target_MIPS32 --need=allow_dump \
; RUN: --command %p2i --filetype=asm --assemble --disassemble --target mips32\
; RUN: -i %s --args -Om1 --skip-unimplemented \
; RUN: -allow-externally-defined-symbols \
; RUN: | %if --need=target_MIPS32 --need=allow_dump \
; RUN: --command FileCheck --check-prefix MIPS32 %s
declare i8* @llvm.nacl.read.tp()
declare void @llvm.nacl.longjmp(i8*, i32)
declare i32 @llvm.nacl.setjmp(i8*)
......@@ -67,6 +74,8 @@ entry:
; CHECKO2REM: mov e{{.*}},{{(DWORD PTR )?}}gs:0x0
; CHECKO2UNSANDBOXEDREM-LABEL: test_nacl_read_tp
; CHECKO2UNSANDBOXEDREM: call {{.*}} R_{{.*}} __nacl_read_tp
; MIPS32-LABEL: test_nacl_read_tp
; MIPS32: jal {{.*}} __nacl_read_tp
define internal i32 @test_nacl_read_tp_more_addressing() {
entry:
......@@ -94,6 +103,8 @@ entry:
; CHECKO2UNSANDBOXEDREM-LABEL: test_nacl_read_tp_more_addressing
; CHECKO2UNSANDBOXEDREM: call {{.*}} R_{{.*}} __nacl_read_tp
; CHECKO2UNSANDBOXEDREM: call {{.*}} R_{{.*}} __nacl_read_tp
; MIPS32-LABEL: test_nacl_read_tp_more_addressing
; MIPS32: jal {{.*}} __nacl_read_tp
define internal i32 @test_nacl_read_tp_dead(i32 %a) {
entry:
......@@ -107,6 +118,8 @@ entry:
; CHECKO2REM-NOT: mov e{{.*}}, DWORD PTR gs:0x0
; CHECKO2UNSANDBOXEDREM-LABEL: test_nacl_read_tp_dead
; CHECKO2UNSANDBOXEDREM-NOT: call {{.*}} R_{{.*}} __nacl_read_tp
; MIPS32-LABEL: test_nacl_read_tp_dead
; MIPS32: jal {{.*}} __nacl_read_tp
define internal i32 @test_setjmplongjmp(i32 %iptr_env) {
entry:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment