[llvm] r259863 - Add various binary operations in the LLVM C API echo test
Amaury Sechet via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 17:27:11 PST 2016
Author: deadalnix
Date: Thu Feb 4 19:27:11 2016
New Revision: 259863
URL: http://llvm.org/viewvc/llvm-project?rev=259863&view=rev
Log:
Add various binary operations in the LLVM C API echo test
Summary: This diff increase the tested surface of the C API.
Reviewers: bogner, chandlerc, echristo, dblaikie, joker.eph, Wallbraker
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D16910
Modified:
llvm/trunk/test/Bindings/llvm-c/echo.ll
llvm/trunk/tools/llvm-c-test/echo.cpp
Modified: llvm/trunk/test/Bindings/llvm-c/echo.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/llvm-c/echo.ll?rev=259863&r1=259862&r2=259863&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/llvm-c/echo.ll (original)
+++ llvm/trunk/test/Bindings/llvm-c/echo.ll Thu Feb 4 19:27:11 2016
@@ -21,12 +21,24 @@ define void @types() {
ret void
}
-define i32 @add(i32 %a, i32 %b) {
+define i32 @iops(i32 %a, i32 %b) {
%1 = add i32 %a, %b
- ret i32 %1
+ %2 = mul i32 %a, %1
+ %3 = sub i32 %2, %1
+ %4 = udiv i32 %3, %b
+ %5 = sdiv i32 %2, %4
+ %6 = urem i32 %3, %5
+ %7 = srem i32 %2, %6
+ %8 = shl i32 %1, %b
+ %9 = lshr i32 %a, %7
+ %10 = ashr i32 %b, %8
+ %11 = and i32 %9, %10
+ %12 = or i32 %2, %11
+ %13 = xor i32 %12, %4
+ ret i32 %13
}
define i32 @call() {
- %1 = call i32 @add(i32 23, i32 19)
+ %1 = call i32 @iops(i32 23, i32 19)
ret i32 %1
}
Modified: llvm/trunk/tools/llvm-c-test/echo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-c-test/echo.cpp?rev=259863&r1=259862&r2=259863&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-c-test/echo.cpp (original)
+++ llvm/trunk/tools/llvm-c-test/echo.cpp Thu Feb 4 19:27:11 2016
@@ -215,6 +215,78 @@ static LLVMValueRef clone_value(LLVMValu
Dst = LLVMBuildAdd(Builder, LHS, RHS, Name);
break;
}
+ case LLVMSub: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildSub(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMMul: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildMul(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMUDiv: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildUDiv(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMSDiv: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildSDiv(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMURem: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildURem(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMSRem: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildSRem(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMShl: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildShl(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMLShr: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildLShr(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMAShr: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildAShr(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMAnd: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildAnd(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMOr: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildOr(Builder, LHS, RHS, Name);
+ break;
+ }
+ case LLVMXor: {
+ LLVMValueRef LHS = clone_value(LLVMGetOperand(Src, 0), Builder, VMap);
+ LLVMValueRef RHS = clone_value(LLVMGetOperand(Src, 1), Builder, VMap);
+ Dst = LLVMBuildXor(Builder, LHS, RHS, Name);
+ break;
+ }
case LLVMAlloca: {
LLVMTypeRef Ty = LLVMGetElementType(LLVMTypeOf(Src));
Dst = LLVMBuildAlloca(Builder, Ty, Name);
More information about the llvm-commits
mailing list