1 //===- NaClBitcodeDecoders.h -------------------------------------*- C++ 2 //-*-===// 3 // Functions used to decode values in PNaCl bitcode files. 4 // 5 // The LLVM Compiler Infrastructure 6 // 7 // This file is distributed under the University of Illinois Open Source 8 // License. See LICENSE.TXT for details. 9 // 10 //===----------------------------------------------------------------------===// 11 // 12 // This header file provides a public API for value decoders defined in 13 // the PNaCl bitcode reader. 14 // 15 //===----------------------------------------------------------------------===// 16 17 #ifndef LLVM_BITCODE_NACL_NACLBITCODEDECODERS_H 18 #define LLVM_BITCODE_NACL_NACLBITCODEDECODERS_H 19 20 #include "llvm/Bitcode/NaCl/NaClLLVMBitCodes.h" 21 #include "llvm/IR/CallingConv.h" 22 #include "llvm/IR/GlobalValue.h" 23 #include "llvm/IR/InstrTypes.h" 24 #include "llvm/IR/Instruction.h" 25 26 namespace llvm { 27 namespace naclbitc { 28 29 /// Converts the NaCl (bitcode file) cast opcode to the corresponding 30 /// LLVM cast opcode. Returns true if the conversion 31 /// succeeds. Otherwise sets LLVMOpcode to Instruction::BitCast and 32 /// returns false. 33 bool DecodeCastOpcode(uint64_t NaClOpcode, Instruction::CastOps &LLVMOpcode); 34 35 /// Converts the NaCl (bitcode file) linkage type to the corresponding 36 /// LLVM linkage type. Returns true if the conversion 37 /// succeeds. Otherwise sets LLVMLinkage to 38 /// GlobalValue::InternalLinkage and returns false. 39 bool DecodeLinkage(uint64_t NaClLinkage, 40 GlobalValue::LinkageTypes &LLVMLinkage); 41 42 /// Converts the NaCl (bitcode file) binary opcode to the 43 /// corresponding LLVM binary opcode, assuming that the operator 44 /// operates on OpType. Returns true if the conversion 45 /// succeeds. Otherwise sets LLVMOpcode to Instruction::Add and 46 /// returns false. 47 bool DecodeBinaryOpcode(uint64_t NaClOpcode, Type *OpType, 48 Instruction::BinaryOps &LLVMOpcode); 49 50 /// Converts the NaCl (bitcode file) calling convention value to the 51 /// corresponding LLVM calling conventions. Returns true if the 52 /// conversion succeeds. Otherwise sets LLVMCallingConv to 53 /// CallingConv::C and returns false. 54 bool DecodeCallingConv(uint64_t NaClCallingConv, 55 CallingConv::ID &LLVMCallingConv); 56 57 /// Converts the NaCl (bitcode file) float comparison predicate to the 58 /// corresponding LLVM float comparison predicate. Returns true if the 59 /// conversion succeeds. Otherwise sets LLVMPredicate to 60 /// CmpInst::FCMP_FALSE and returns false. 61 bool DecodeFcmpPredicate(uint64_t NaClPredicate, 62 CmpInst::Predicate &LLVMPredicate); 63 64 /// Converts the NaCl (bitcode file) integer comparison predicate to 65 /// the corresponding LLVM integer comparison predicate. Returns true 66 /// if the conversion succeeds. Otherwise sets LLVMPredicate to 67 /// CmpInst::ICMP_EQ and returns false. 68 bool DecodeIcmpPredicate(uint64_t NaClPredicate, 69 CmpInst::Predicate &LLVMPredicate); 70 71 } // namespace naclbitc 72 } // namespace llvm 73 74 #endif 75