llvm.org GIT mirror llvm / 3f52c15
Add new interface that allows removal of some code from the code generators, provides for future extensibility, might help the LLVA project avoid having to hack their own LLI, and provides support required for the experimental Venus project. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10620 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
2 changed file(s) with 126 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //===-- llvm/CodeGen/IntrinsicLowering.h - Intrinsic Lowering ---*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by the LLVM research group and is distributed under
5 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the IntrinsicLowering interface. This interface allows
10 // addition of domain-specific or front-end specific intrinsics to LLVM without
11 // having to modify all of the target-machines to support the new intrinsic.
12 // Later, as desired, code generators can incrementally add support for
13 // particular intrinsic functions, as desired, to generate better code.
14 //
15 // If a code generator cannot handle or does not know about an intrinsic
16 // function, it will use the intrinsic lowering interface to change an intrinsic
17 // function name into a concrete function name which can be used to implement
18 // the functionality of the intrinsic. For example, llvm.acos can be
19 // implemented as a call to the math library 'acos' function if the target
20 // doesn't have hardware support for the intrinsic, or if it has not yet been
21 // implemented yet.
22 //
23 // Another use for this interface is the addition of domain-specific intrinsics.
24 // The default implementation of this interface would then lower the intrinsics
25 // to noop calls, allowing the direct execution of programs with instrumentation
26 // or other hooks placed in them. When a specific tool or flag is used, a
27 // different implementation of these interfaces may be used, which activates the
28 // intrinsics in some way.
29 //
30 //===----------------------------------------------------------------------===//
31
32 #ifndef LLVM_CODEGEN_INTRINSICLOWERING_H
33 #define LLVM_CODEGEN_INTRINSICLOWERING_H
34
35 namespace llvm {
36 class CallInst;
37
38 struct IntrinsicLowering {
39
40 /// LowerIntrinsicCall - This method returns the LLVM function which should
41 /// be used to implement the specified intrinsic function call. If an
42 /// intrinsic function must be implemented by the code generator (such as
43 /// va_start), this function should print a message and abort.
44 ///
45 /// Otherwise, if an intrinsic function call can be lowered, the code to
46 /// implement it (often a call to a non-intrinsic function) is inserted
47 /// _after_ the call instruction and the call is deleted. The caller must
48 /// be capable of handling this kind of change.
49 ///
50 virtual void LowerIntrinsicCall(CallInst *CI) = 0;
51 };
52
53 /// DefaultIntrinsicLower - This is the default intrinsic lowering pass which
54 /// is used if no other one is specified. Custom intrinsic lowering
55 /// implementations should pass any unhandled intrinsics to this
56 /// implementation to allow for future extensibility.
57 struct DefaultIntrinsicLowering : public IntrinsicLowering {
58 virtual void LowerIntrinsicCall(CallInst *CI);
59 };
60 }
61
62 #endif
0 //===-- llvm/CodeGen/IntrinsicLowering.h - Intrinsic Lowering ---*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by the LLVM research group and is distributed under
5 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the IntrinsicLowering interface. This interface allows
10 // addition of domain-specific or front-end specific intrinsics to LLVM without
11 // having to modify all of the target-machines to support the new intrinsic.
12 // Later, as desired, code generators can incrementally add support for
13 // particular intrinsic functions, as desired, to generate better code.
14 //
15 // If a code generator cannot handle or does not know about an intrinsic
16 // function, it will use the intrinsic lowering interface to change an intrinsic
17 // function name into a concrete function name which can be used to implement
18 // the functionality of the intrinsic. For example, llvm.acos can be
19 // implemented as a call to the math library 'acos' function if the target
20 // doesn't have hardware support for the intrinsic, or if it has not yet been
21 // implemented yet.
22 //
23 // Another use for this interface is the addition of domain-specific intrinsics.
24 // The default implementation of this interface would then lower the intrinsics
25 // to noop calls, allowing the direct execution of programs with instrumentation
26 // or other hooks placed in them. When a specific tool or flag is used, a
27 // different implementation of these interfaces may be used, which activates the
28 // intrinsics in some way.
29 //
30 //===----------------------------------------------------------------------===//
31
32 #ifndef LLVM_CODEGEN_INTRINSICLOWERING_H
33 #define LLVM_CODEGEN_INTRINSICLOWERING_H
34
35 namespace llvm {
36 class CallInst;
37
38 struct IntrinsicLowering {
39
40 /// LowerIntrinsicCall - This method returns the LLVM function which should
41 /// be used to implement the specified intrinsic function call. If an
42 /// intrinsic function must be implemented by the code generator (such as
43 /// va_start), this function should print a message and abort.
44 ///
45 /// Otherwise, if an intrinsic function call can be lowered, the code to
46 /// implement it (often a call to a non-intrinsic function) is inserted
47 /// _after_ the call instruction and the call is deleted. The caller must
48 /// be capable of handling this kind of change.
49 ///
50 virtual void LowerIntrinsicCall(CallInst *CI) = 0;
51 };
52
53 /// DefaultIntrinsicLower - This is the default intrinsic lowering pass which
54 /// is used if no other one is specified. Custom intrinsic lowering
55 /// implementations should pass any unhandled intrinsics to this
56 /// implementation to allow for future extensibility.
57 struct DefaultIntrinsicLowering : public IntrinsicLowering {
58 virtual void LowerIntrinsicCall(CallInst *CI);
59 };
60 }
61
62 #endif