зеркало из https://github.com/dotnet/llilc.git
Implement the sqrt intrinsic
Lower this to LLVM's sqrt intrinsic, which on x64 turns into an SSE2 sqrt instruction.
This commit is contained in:
Родитель
dbd11eda17
Коммит
f8771e9082
|
@ -2894,7 +2894,13 @@ public:
|
|||
virtual void storeStaticField(CORINFO_RESOLVED_TOKEN *FieldToken,
|
||||
IRNode *ValueToStore, bool IsVolatile) = 0;
|
||||
virtual IRNode *stringGetChar(IRNode *Arg1, IRNode *Arg2) = 0;
|
||||
virtual bool sqrt(IRNode *Arg1, IRNode **RetVal) = 0;
|
||||
|
||||
/// Optionally generate inline code for the \p sqrt operation
|
||||
///
|
||||
/// \param Argument input value for sqrt
|
||||
/// \param Result [out] resulting sqrt value, iff reader decided to expand
|
||||
/// \returns true iff Result represents the sqrt
|
||||
virtual bool sqrt(IRNode *Argument, IRNode **Result) = 0;
|
||||
|
||||
virtual bool interlockedIntrinsicBinOp(IRNode *Arg1, IRNode *Arg2,
|
||||
IRNode **RetVal,
|
||||
|
|
|
@ -458,10 +458,7 @@ public:
|
|||
IRNode *ValueToStore, bool IsVolatile) override;
|
||||
|
||||
IRNode *stringGetChar(IRNode *Arg1, IRNode *Arg2) override;
|
||||
|
||||
bool sqrt(IRNode *Arg1, IRNode **RetVal) override {
|
||||
throw NotYetImplementedException("sqrt");
|
||||
};
|
||||
bool sqrt(IRNode *Argument, IRNode **Result) override;
|
||||
|
||||
// The callTarget node is only required on IA64.
|
||||
bool interlockedIntrinsicBinOp(IRNode *Arg1, IRNode *Arg2, IRNode **RetVal,
|
||||
|
|
|
@ -5479,6 +5479,22 @@ bool GenIR::abs(IRNode *Argument, IRNode **Result) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool GenIR::sqrt(IRNode *Argument, IRNode **Result) {
|
||||
Type *Ty = Argument->getType();
|
||||
|
||||
if (Ty->isFloatingPointTy()) {
|
||||
Type *Types[] = {Ty};
|
||||
Value *FSqrt = Intrinsic::getDeclaration(JitContext->CurrentModule,
|
||||
Intrinsic::sqrt, Types);
|
||||
bool MayThrow = false;
|
||||
Value *Sqrt = makeCall(FSqrt, MayThrow, Argument).getInstruction();
|
||||
*Result = (IRNode *)Sqrt;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
IRNode *GenIR::localAlloc(IRNode *Arg, bool ZeroInit) {
|
||||
// Note that we've seen a localloc in this method, since it has repercussions
|
||||
// on other aspects of code generation.
|
||||
|
|
Загрузка…
Ссылка в новой задаче