An "autoconf wrapper" for the infamous windows.h file
[oota-llvm.git] / include / llvm / 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 #include "llvm/Intrinsics.h"
37
38 namespace llvm {
39   class CallInst;
40   class Module;
41   
42   struct IntrinsicLowering {
43     virtual ~IntrinsicLowering() {}
44
45     /// AddPrototypes - This method, if called, causes all of the prototypes
46     /// that might be needed by an intrinsic lowering implementation to be
47     /// inserted into the module specified.
48     virtual void AddPrototypes(Module &M) = 0;
49
50     /// LowerIntrinsicCall - This method returns the LLVM function which should
51     /// be used to implement the specified intrinsic function call.  If an
52     /// intrinsic function must be implemented by the code generator (such as
53     /// va_start), this function should print a message and abort.
54     ///
55     /// Otherwise, if an intrinsic function call can be lowered, the code to
56     /// implement it (often a call to a non-intrinsic function) is inserted
57     /// _after_ the call instruction and the call is deleted.  The caller must
58     /// be capable of handling this kind of change.
59     ///
60     virtual void LowerIntrinsicCall(CallInst *CI) = 0;
61   };
62
63   /// DefaultIntrinsicLower - This is the default intrinsic lowering pass which
64   /// is used if no other one is specified.  Custom intrinsic lowering
65   /// implementations should pass any unhandled intrinsics to this
66   /// implementation to allow for future extensibility.
67   struct DefaultIntrinsicLowering : public IntrinsicLowering {
68     virtual void AddPrototypes(Module &M);
69     virtual void LowerIntrinsicCall(CallInst *CI);    
70   };
71 }
72
73 #endif