1193323Sed//===-- IntrinsicLowering.h - Intrinsic Function Lowering -------*- C++ -*-===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10193323Sed// This file defines the IntrinsicLowering interface.  This interface allows
11193323Sed// addition of domain-specific or front-end specific intrinsics to LLVM without
12193323Sed// having to modify all of the C backend or interpreter.
13193323Sed//
14193323Sed//===----------------------------------------------------------------------===//
15193323Sed
16193323Sed#ifndef LLVM_CODEGEN_INTRINSICLOWERING_H
17193323Sed#define LLVM_CODEGEN_INTRINSICLOWERING_H
18193323Sed
19249423Sdim#include "llvm/IR/Intrinsics.h"
20193323Sed
21193323Sednamespace llvm {
22193323Sed  class CallInst;
23193323Sed  class Module;
24243830Sdim  class DataLayout;
25193323Sed
26193323Sed  class IntrinsicLowering {
27243830Sdim    const DataLayout& TD;
28195098Sed
29195098Sed
30195098Sed    bool Warned;
31193323Sed  public:
32243830Sdim    explicit IntrinsicLowering(const DataLayout &td) :
33195098Sed      TD(td), Warned(false) {}
34193323Sed
35193323Sed    /// AddPrototypes - This method, if called, causes all of the prototypes
36193323Sed    /// that might be needed by an intrinsic lowering implementation to be
37193323Sed    /// inserted into the module specified.
38193323Sed    void AddPrototypes(Module &M);
39193323Sed
40193323Sed    /// LowerIntrinsicCall - This method replaces a call with the LLVM function
41193323Sed    /// which should be used to implement the specified intrinsic function call.
42193323Sed    /// If an intrinsic function must be implemented by the code generator
43193323Sed    /// (such as va_start), this function should print a message and abort.
44193323Sed    ///
45193323Sed    /// Otherwise, if an intrinsic function call can be lowered, the code to
46193323Sed    /// implement it (often a call to a non-intrinsic function) is inserted
47193323Sed    /// _after_ the call instruction and the call is deleted.  The caller must
48193323Sed    /// be capable of handling this kind of change.
49193323Sed    ///
50193323Sed    void LowerIntrinsicCall(CallInst *CI);
51218893Sdim
52218893Sdim    /// LowerToByteSwap - Replace a call instruction into a call to bswap
53218893Sdim    /// intrinsic. Return false if it has determined the call is not a
54218893Sdim    /// simple integer bswap.
55218893Sdim    static bool LowerToByteSwap(CallInst *CI);
56193323Sed  };
57193323Sed}
58193323Sed
59193323Sed#endif
60