1 //===-- llvm/IntrinsicLowering.h - Intrinsic Function Lowering --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the IntrinsicLowering interface. This interface allows
11 // addition of domain-specific or front-end specific intrinsics to LLVM without
12 // having to modify all of the target-machines to support the new intrinsic.
13 // Later, as desired, code generators can incrementally add support for
14 // particular intrinsic functions, as desired, to generate better code.
16 // If a code generator cannot handle or does not know about an intrinsic
17 // function, it will use the intrinsic lowering interface to change an intrinsic
18 // function name into a concrete function name which can be used to implement
19 // the functionality of the intrinsic. For example, llvm.acos can be
20 // implemented as a call to the math library 'acos' function if the target
21 // doesn't have hardware support for the intrinsic, or if it has not yet been
24 // Another use for this interface is the addition of domain-specific intrinsics.
25 // The default implementation of this interface would then lower the intrinsics
26 // to noop calls, allowing the direct execution of programs with instrumentation
27 // or other hooks placed in them. When a specific tool or flag is used, a
28 // different implementation of these interfaces may be used, which activates the
29 // intrinsics in some way.
31 //===----------------------------------------------------------------------===//
33 #ifndef LLVM_INTRINSICLOWERING_H
34 #define LLVM_INTRINSICLOWERING_H
36 #include "llvm/Intrinsics.h"
41 struct IntrinsicLowering {
42 virtual ~IntrinsicLowering() {}
44 /// LowerIntrinsicCall - This method returns the LLVM function which should
45 /// be used to implement the specified intrinsic function call. If an
46 /// intrinsic function must be implemented by the code generator (such as
47 /// va_start), this function should print a message and abort.
49 /// Otherwise, if an intrinsic function call can be lowered, the code to
50 /// implement it (often a call to a non-intrinsic function) is inserted
51 /// _after_ the call instruction and the call is deleted. The caller must
52 /// be capable of handling this kind of change.
54 virtual void LowerIntrinsicCall(CallInst *CI) = 0;
57 /// DefaultIntrinsicLower - This is the default intrinsic lowering pass which
58 /// is used if no other one is specified. Custom intrinsic lowering
59 /// implementations should pass any unhandled intrinsics to this
60 /// implementation to allow for future extensibility.
61 struct DefaultIntrinsicLowering : public IntrinsicLowering {
62 virtual void LowerIntrinsicCall(CallInst *CI);