LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

IntrinsicLowering.h

Go to the documentation of this file.
00001 //===-- IntrinsicLowering.h - Intrinsic Function Lowering -------*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 // 
00010 // This file defines the IntrinsicLowering interface.  This interface allows
00011 // addition of domain-specific or front-end specific intrinsics to LLVM without
00012 // having to modify all of the code generators to support the new intrinsic.
00013 // Later, as desired, targets can incrementally add support for particular
00014 // intrinsic functions, as desired, to generate better code.
00015 //
00016 // If a code generator cannot handle or does not know about an intrinsic
00017 // function, it will use the intrinsic lowering interface to change an intrinsic
00018 // function name into a concrete function name which can be used to implement
00019 // the functionality of the intrinsic.  For example, llvm.memcpy can be
00020 // implemented as a call to the math library 'memcpy' function if the target
00021 // doesn't have hardware support for the intrinsic, or if it has not yet been
00022 // implemented yet.
00023 //
00024 // Another use for this interface is the addition of domain-specific intrinsics.
00025 // The default implementation of this interface would then lower the intrinsics
00026 // to noop calls, allowing the direct execution of programs with instrumentation
00027 // or other hooks placed in them.  When a specific tool or flag is used, a
00028 // different implementation of these interfaces may be used, which activates the
00029 // intrinsics in some way.
00030 //
00031 //===----------------------------------------------------------------------===//
00032 
00033 #ifndef LLVM_CODEGEN_INTRINSICLOWERING_H
00034 #define LLVM_CODEGEN_INTRINSICLOWERING_H
00035 
00036 #include "llvm/Intrinsics.h"
00037 
00038 namespace llvm {
00039   class CallInst;
00040   class Module;
00041   
00042   class IntrinsicLowering {
00043   public:
00044     virtual ~IntrinsicLowering() {}
00045 
00046     /// AddPrototypes - This method, if called, causes all of the prototypes
00047     /// that might be needed by an intrinsic lowering implementation to be
00048     /// inserted into the module specified.
00049     virtual void AddPrototypes(Module &M) = 0;
00050 
00051     /// LowerIntrinsicCall - This method returns the LLVM function which should
00052     /// be used to implement the specified intrinsic function call.  If an
00053     /// intrinsic function must be implemented by the code generator (such as
00054     /// va_start), this function should print a message and abort.
00055     ///
00056     /// Otherwise, if an intrinsic function call can be lowered, the code to
00057     /// implement it (often a call to a non-intrinsic function) is inserted
00058     /// _after_ the call instruction and the call is deleted.  The caller must
00059     /// be capable of handling this kind of change.
00060     ///
00061     virtual void LowerIntrinsicCall(CallInst *CI) = 0;
00062   };
00063 
00064   /// DefaultIntrinsicLower - This is the default intrinsic lowering pass which
00065   /// is used if no other one is specified.  Custom intrinsic lowering
00066   /// implementations should pass any unhandled intrinsics to this
00067   /// implementation to allow for future extensibility.
00068   struct DefaultIntrinsicLowering : public IntrinsicLowering {
00069     virtual void AddPrototypes(Module &M);
00070     virtual void LowerIntrinsicCall(CallInst *CI);    
00071   };
00072 }
00073 
00074 #endif