本文整理汇总了C#中LLVMSharp.LLVMValueRef.TypeOf方法的典型用法代码示例。如果您正苦于以下问题:C# LLVMValueRef.TypeOf方法的具体用法?C# LLVMValueRef.TypeOf怎么用?C# LLVMValueRef.TypeOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLVMSharp.LLVMValueRef
的用法示例。
在下文中一共展示了LLVMValueRef.TypeOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateFloatingPointMath
private LLVMValueRef GenerateFloatingPointMath(string op, LLVMValueRef lhs, LLVMValueRef rhs,
LLVMBuilderRef builder)
{
Debug.Assert(lhs.TypeOf().TypeKind == LLVM.Int32Type().TypeKind ||
lhs.TypeOf().TypeKind == LLVM.DoubleType().TypeKind);
Debug.Assert(rhs.TypeOf().TypeKind == LLVM.Int32Type().TypeKind ||
rhs.TypeOf().TypeKind == LLVM.DoubleType().TypeKind);
// Promotion for floats and ints to work together -- very fragile. Need to do better type checking.
if (lhs.TypeOf().TypeKind == LLVM.Int32Type().TypeKind)
{
lhs = LLVM.BuildSIToFP(builder, lhs, LLVM.DoubleType(), "");
}
if (rhs.TypeOf().TypeKind == LLVM.Int32Type().TypeKind)
{
rhs = LLVM.BuildSIToFP(builder, rhs, LLVM.DoubleType(), "");
}
if (op == "+")
{
return LLVM.BuildFAdd(builder, lhs, rhs, "");
}
else if (op == "-")
{
return LLVM.BuildFSub(builder, lhs, rhs, "");
}
else if (op == "*")
{
return LLVM.BuildFMul(builder, lhs, rhs, "");
}
else if (op == "/")
{
return LLVM.BuildFDiv(builder, lhs, rhs, "");
}
else if (op == "%")
{
return LLVM.BuildFRem(builder, lhs, rhs, "");
}
else if (op == "<")
{
return LLVM.BuildFCmp(builder, LLVMRealPredicate.LLVMRealOLT, lhs, rhs, "");
}
else if (op == ">")
{
return LLVM.BuildFCmp(builder, LLVMRealPredicate.LLVMRealOGT, lhs, rhs, "");
}
else if (op == "==")
{
return LLVM.BuildFCmp(builder, LLVMRealPredicate.LLVMRealOEQ, lhs, rhs, "");
}
else if (op == ">=")
{
return LLVM.BuildFCmp(builder, LLVMRealPredicate.LLVMRealOGE, lhs, rhs, "");
}
else if (op == "<=")
{
return LLVM.BuildFCmp(builder, LLVMRealPredicate.LLVMRealOLE, lhs, rhs, "");
}
else
{
throw new Exception("unknown operator");
}
}
示例2: GenerateIntegerMath
private LLVMValueRef GenerateIntegerMath(string op, LLVMValueRef lhs, LLVMValueRef rhs, LLVMBuilderRef builder)
{
Debug.Assert(lhs.TypeOf().TypeKind == LLVM.Int32Type().TypeKind);
Debug.Assert(rhs.TypeOf().TypeKind == LLVM.Int32Type().TypeKind);
if (op == "+")
{
return LLVM.BuildAdd(builder, lhs, rhs, "");
}
else if (op == "-")
{
return LLVM.BuildSub(builder, lhs, rhs, "");
}
else if (op == "*")
{
return LLVM.BuildMul(builder, lhs, rhs, "");
}
else if (op == "/")
{
return LLVM.BuildSDiv(builder, lhs, rhs, "");
}
else if (op == "%")
{
return LLVM.BuildSRem(builder, lhs, rhs, "");
}
else if (op == "<")
{
return LLVM.BuildICmp(builder, LLVMIntPredicate.LLVMIntSLT, lhs, rhs, "");
}
else if (op == ">")
{
return LLVM.BuildICmp(builder, LLVMIntPredicate.LLVMIntSGT, lhs, rhs, "");
}
else if (op == "==")
{
return LLVM.BuildICmp(builder, LLVMIntPredicate.LLVMIntEQ, lhs, rhs, "");
}
else if (op == ">=")
{
return LLVM.BuildICmp(builder, LLVMIntPredicate.LLVMIntSGE, lhs, rhs, "");
}
else if (op == "<=")
{
return LLVM.BuildICmp(builder, LLVMIntPredicate.LLVMIntSLE, lhs, rhs, "");
}
else
{
throw new Exception("unknown operator");
}
}