mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Implement the default implementation of the intrinsic lowering class
llvm-svn: 10621
This commit is contained in:
parent
8bc92e92ee
commit
57ff7c242c
57
lib/CodeGen/IntrinsicLowering.cpp
Normal file
57
lib/CodeGen/IntrinsicLowering.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
//===-- IntrinsicLowering.cpp - Intrinsic Lowering default implementation -===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the default intrinsic lowering implementation.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/CodeGen/IntrinsicLowering.h"
|
||||
#include "llvm/Constant.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/iOther.h"
|
||||
using namespace llvm;
|
||||
|
||||
void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
assert(Callee && "Cannot lower an indirect call!");
|
||||
|
||||
Module *M = Callee->getParent();
|
||||
|
||||
switch (Callee->getIntrinsicID()) {
|
||||
case Intrinsic::not_intrinsic:
|
||||
std::cerr << "Cannot lower a call to a non-intrinsic function '"
|
||||
<< Callee->getName() << "'!\n";
|
||||
abort();
|
||||
default:
|
||||
std::cerr << "Error: Code generator does not support intrinsic function '"
|
||||
<< Callee->getName() << "'!\n";
|
||||
abort();
|
||||
|
||||
// The default implementation of setjmp/longjmp transforms setjmp into a
|
||||
// noop that always returns zero and longjmp into a call to abort. This
|
||||
// allows code that never longjmps to work correctly.
|
||||
case Intrinsic::setjmp:
|
||||
case Intrinsic::sigsetjmp:
|
||||
if (CI->getType() != Type::VoidTy)
|
||||
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
|
||||
break;
|
||||
|
||||
case Intrinsic::longjmp:
|
||||
case Intrinsic::siglongjmp:
|
||||
// Insert the call to abort
|
||||
new CallInst(M->getOrInsertFunction("abort", Type::VoidTy, 0), "", CI);
|
||||
break;
|
||||
}
|
||||
|
||||
assert(CI->use_empty() &&
|
||||
"Lowering should have eliminated any uses of the intrinsic call!");
|
||||
CI->getParent()->getInstList().erase(CI);
|
||||
}
|
Loading…
Reference in New Issue
Block a user