Move header into top-level llvm dir
[oota-llvm.git] / include / llvm / CodeGen / IntrinsicLowering.h
1 //===-- llvm/IntrinsicLowering.h - Intrinsic Function Lowering --*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 // 
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.
15 //
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
22 // implemented yet.
23 //
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.
30 //
31 //===----------------------------------------------------------------------===//
32
33 #ifndef LLVM_INTRINSICLOWERING_H
34 #define LLVM_INTRINSICLOWERING_H
35
36 namespace llvm {
37   class CallInst;
38   
39   struct IntrinsicLowering {
40
41     /// LowerIntrinsicCall - This method returns the LLVM function which should
42     /// be used to implement the specified intrinsic function call.  If an
43     /// intrinsic function must be implemented by the code generator (such as
44     /// va_start), this function should print a message and abort.
45     ///
46     /// Otherwise, if an intrinsic function call can be lowered, the code to
47     /// implement it (often a call to a non-intrinsic function) is inserted
48     /// _after_ the call instruction and the call is deleted.  The caller must
49     /// be capable of handling this kind of change.
50     ///
51     virtual void LowerIntrinsicCall(CallInst *CI) = 0;
52   };
53
54   /// DefaultIntrinsicLower - This is the default intrinsic lowering pass which
55   /// is used if no other one is specified.  Custom intrinsic lowering
56   /// implementations should pass any unhandled intrinsics to this
57   /// implementation to allow for future extensibility.
58   struct DefaultIntrinsicLowering : public IntrinsicLowering {
59     virtual void LowerIntrinsicCall(CallInst *CI);    
60   };
61 }
62
63 #endif