1 //===- NaClBitcodeDecoders.h -------------------------------------*- C++ -*-===// 2 // Functions used to decode values in PNaCl bitcode files. 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is distributed under the University of Illinois Open Source 7 // License. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 // 11 // This header file provides a public API for value decoders defined in 12 // the PNaCl bitcode reader. 13 // 14 //===----------------------------------------------------------------------===// 15 16 #ifndef LLVM_BITCODE_NACL_NACLBITCODEDECODERS_H 17 #define LLVM_BITCODE_NACL_NACLBITCODEDECODERS_H 18 19 #include "llvm/IR/CallingConv.h" 20 #include "llvm/IR/GlobalValue.h" 21 #include "llvm/IR/InstrTypes.h" 22 #include "llvm/IR/Instruction.h" 23 #include "llvm/Bitcode/NaCl/NaClLLVMBitCodes.h" 24 25 namespace llvm { 26 namespace naclbitc { 27 28 /// Converts the NaCl (bitcode file) cast opcode to the corresponding 29 /// LLVM cast opcode. Returns true if the conversion 30 /// succeeds. Otherwise sets LLVMOpcode to Instruction::BitCast and 31 /// returns false. 32 bool DecodeCastOpcode(uint64_t NaClOpcode, 33 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 } 72 } 73 74 #endif 75