seanyoung updated this revision to Diff 312172. seanyoung added a comment. Add tests cases for _ExtInt on BPF. This makes the _ExtInt testing equivalent to the testing on every platform except x86-64.
The use-case is to use _ExtInt on BPF when targeting Solana BPF smart contracts. I am writing a solidity to BPF compiler which includes a standard library written in C. Solidity has types of 256 bits. https://github.com/hyperledger-labs/solang/blob/master/stdlib/bigint.c#L378 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93103/new/ https://reviews.llvm.org/D93103 Files: clang/lib/Basic/Targets/BPF.h clang/test/CodeGen/ext-int-cc.c Index: clang/test/CodeGen/ext-int-cc.c =================================================================== --- clang/test/CodeGen/ext-int-cc.c +++ clang/test/CodeGen/ext-int-cc.c @@ -28,6 +28,7 @@ // RUN: %clang_cc1 -triple arm64_32-apple-ios -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64 // RUN: %clang_cc1 -triple arm64_32-apple-ios -target-abi darwinpcs -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64DARWIN // RUN: %clang_cc1 -triple arm -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=ARM +// RUN: %clang_cc1 -triple bpf -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=BPF // Make sure 128 and 64 bit versions are passed like integers, and that >128 // is passed indirectly. @@ -59,6 +60,7 @@ // AARCH64: define void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}}) // AARCH64DARWIN: define void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}}) // ARM: define arm_aapcscc void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128* byval(i128) align 8 %{{.+}}, i64 %{{.+}}) +// BPF: define void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}}) void ParamPassing2(_ExtInt(129) a, _ExtInt(127) b, _ExtInt(63) c) {} // LIN64: define void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}) @@ -88,6 +90,7 @@ // AARCH64: define void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}}) // AARCH64DARWIN: define void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}}) // ARM: define arm_aapcscc void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127* byval(i127) align 8 %{{.+}}, i63 %{{.+}}) +// BPF: define void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}}) // Make sure we follow the signext rules for promotable integer types. void ParamPassing3(_ExtInt(15) a, _ExtInt(31) b) {} @@ -118,6 +121,7 @@ // AARCH64: define void @ParamPassing3(i15 %{{.+}}, i31 %{{.+}}) // AARCH64DARWIN: define void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) // ARM: define arm_aapcscc void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) +// BPF: define void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) _ExtInt(63) ReturnPassing(){} // LIN64: define i64 @ReturnPassing( @@ -147,6 +151,7 @@ // AARCH64: define i63 @ReturnPassing( // AARCH64DARWIN: define i63 @ReturnPassing( // ARM: define arm_aapcscc i63 @ReturnPassing( +// BPF: define i63 @ReturnPassing( _ExtInt(64) ReturnPassing2(){} // LIN64: define i64 @ReturnPassing2( @@ -176,6 +181,7 @@ // AARCH64: define i64 @ReturnPassing2( // AARCH64DARWIN: define i64 @ReturnPassing2( // ARM: define arm_aapcscc i64 @ReturnPassing2( +// BPF: define i64 @ReturnPassing2( _ExtInt(127) ReturnPassing3(){} // LIN64: define { i64, i64 } @ReturnPassing3( @@ -207,6 +213,7 @@ // AARCH64: define i127 @ReturnPassing3( // AARCH64DARWIN: define i127 @ReturnPassing3( // ARM: define arm_aapcscc void @ReturnPassing3(i127* noalias sret +// BPF: define i127 @ReturnPassing3( _ExtInt(128) ReturnPassing4(){} // LIN64: define { i64, i64 } @ReturnPassing4( @@ -236,6 +243,7 @@ // AARCH64: define i128 @ReturnPassing4( // AARCH64DARWIN: define i128 @ReturnPassing4( // ARM: define arm_aapcscc void @ReturnPassing4(i128* noalias sret +// BPF: define i128 @ReturnPassing4( _ExtInt(129) ReturnPassing5(){} // LIN64: define void @ReturnPassing5(i129* noalias sret @@ -265,6 +273,7 @@ // AARCH64: define void @ReturnPassing5(i129* noalias sret // AARCH64DARWIN: define void @ReturnPassing5(i129* noalias sret // ARM: define arm_aapcscc void @ReturnPassing5(i129* noalias sret +// BPF: define void @ReturnPassing5(i129* noalias sret // SparcV9 is odd in that it has a return-size limit of 256, not 128 or 64 // like other platforms, so test to make sure this behavior will still work. Index: clang/lib/Basic/Targets/BPF.h =================================================================== --- clang/lib/Basic/Targets/BPF.h +++ clang/lib/Basic/Targets/BPF.h @@ -96,6 +96,8 @@ StringRef CPUName(Name); return isValidCPUName(CPUName); } + + bool hasExtIntType() const override { return true; } }; } // namespace targets } // namespace clang
Index: clang/test/CodeGen/ext-int-cc.c =================================================================== --- clang/test/CodeGen/ext-int-cc.c +++ clang/test/CodeGen/ext-int-cc.c @@ -28,6 +28,7 @@ // RUN: %clang_cc1 -triple arm64_32-apple-ios -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64 // RUN: %clang_cc1 -triple arm64_32-apple-ios -target-abi darwinpcs -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64DARWIN // RUN: %clang_cc1 -triple arm -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=ARM +// RUN: %clang_cc1 -triple bpf -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=BPF // Make sure 128 and 64 bit versions are passed like integers, and that >128 // is passed indirectly. @@ -59,6 +60,7 @@ // AARCH64: define void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}}) // AARCH64DARWIN: define void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}}) // ARM: define arm_aapcscc void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128* byval(i128) align 8 %{{.+}}, i64 %{{.+}}) +// BPF: define void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}}) void ParamPassing2(_ExtInt(129) a, _ExtInt(127) b, _ExtInt(63) c) {} // LIN64: define void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}) @@ -88,6 +90,7 @@ // AARCH64: define void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}}) // AARCH64DARWIN: define void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}}) // ARM: define arm_aapcscc void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127* byval(i127) align 8 %{{.+}}, i63 %{{.+}}) +// BPF: define void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127 %{{.+}}, i63 %{{.+}}) // Make sure we follow the signext rules for promotable integer types. void ParamPassing3(_ExtInt(15) a, _ExtInt(31) b) {} @@ -118,6 +121,7 @@ // AARCH64: define void @ParamPassing3(i15 %{{.+}}, i31 %{{.+}}) // AARCH64DARWIN: define void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) // ARM: define arm_aapcscc void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) +// BPF: define void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) _ExtInt(63) ReturnPassing(){} // LIN64: define i64 @ReturnPassing( @@ -147,6 +151,7 @@ // AARCH64: define i63 @ReturnPassing( // AARCH64DARWIN: define i63 @ReturnPassing( // ARM: define arm_aapcscc i63 @ReturnPassing( +// BPF: define i63 @ReturnPassing( _ExtInt(64) ReturnPassing2(){} // LIN64: define i64 @ReturnPassing2( @@ -176,6 +181,7 @@ // AARCH64: define i64 @ReturnPassing2( // AARCH64DARWIN: define i64 @ReturnPassing2( // ARM: define arm_aapcscc i64 @ReturnPassing2( +// BPF: define i64 @ReturnPassing2( _ExtInt(127) ReturnPassing3(){} // LIN64: define { i64, i64 } @ReturnPassing3( @@ -207,6 +213,7 @@ // AARCH64: define i127 @ReturnPassing3( // AARCH64DARWIN: define i127 @ReturnPassing3( // ARM: define arm_aapcscc void @ReturnPassing3(i127* noalias sret +// BPF: define i127 @ReturnPassing3( _ExtInt(128) ReturnPassing4(){} // LIN64: define { i64, i64 } @ReturnPassing4( @@ -236,6 +243,7 @@ // AARCH64: define i128 @ReturnPassing4( // AARCH64DARWIN: define i128 @ReturnPassing4( // ARM: define arm_aapcscc void @ReturnPassing4(i128* noalias sret +// BPF: define i128 @ReturnPassing4( _ExtInt(129) ReturnPassing5(){} // LIN64: define void @ReturnPassing5(i129* noalias sret @@ -265,6 +273,7 @@ // AARCH64: define void @ReturnPassing5(i129* noalias sret // AARCH64DARWIN: define void @ReturnPassing5(i129* noalias sret // ARM: define arm_aapcscc void @ReturnPassing5(i129* noalias sret +// BPF: define void @ReturnPassing5(i129* noalias sret // SparcV9 is odd in that it has a return-size limit of 256, not 128 or 64 // like other platforms, so test to make sure this behavior will still work. Index: clang/lib/Basic/Targets/BPF.h =================================================================== --- clang/lib/Basic/Targets/BPF.h +++ clang/lib/Basic/Targets/BPF.h @@ -96,6 +96,8 @@ StringRef CPUName(Name); return isValidCPUName(CPUName); } + + bool hasExtIntType() const override { return true; } }; } // namespace targets } // namespace clang
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits