1*03ce13f7SAndroid Build Coastguard Worker //===- BitcodeMunge.h - Subzero Bitcode Munger ------------------*- C++ -*-===// 2*03ce13f7SAndroid Build Coastguard Worker // 3*03ce13f7SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*03ce13f7SAndroid Build Coastguard Worker // 5*03ce13f7SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*03ce13f7SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*03ce13f7SAndroid Build Coastguard Worker // 8*03ce13f7SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*03ce13f7SAndroid Build Coastguard Worker // 10*03ce13f7SAndroid Build Coastguard Worker // Test harness for testing malformed bitcode files in Subzero. Uses NaCl's 11*03ce13f7SAndroid Build Coastguard Worker // bitcode munger to do this. 12*03ce13f7SAndroid Build Coastguard Worker // 13*03ce13f7SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 14*03ce13f7SAndroid Build Coastguard Worker 15*03ce13f7SAndroid Build Coastguard Worker #ifndef SUBZERO_UNITTEST_BITCODEMUNGE_H 16*03ce13f7SAndroid Build Coastguard Worker #define SUBZERO_UNITTEST_BITCODEMUNGE_H 17*03ce13f7SAndroid Build Coastguard Worker 18*03ce13f7SAndroid Build Coastguard Worker #pragma clang diagnostic push 19*03ce13f7SAndroid Build Coastguard Worker #pragma clang diagnostic ignored "-Wunused-parameter" 20*03ce13f7SAndroid Build Coastguard Worker #include "llvm/Bitcode/NaCl/NaClBitcodeMunge.h" 21*03ce13f7SAndroid Build Coastguard Worker #pragma clang diagnostic pop 22*03ce13f7SAndroid Build Coastguard Worker 23*03ce13f7SAndroid Build Coastguard Worker #include "IceClFlags.h" 24*03ce13f7SAndroid Build Coastguard Worker #include "IceGlobalContext.h" 25*03ce13f7SAndroid Build Coastguard Worker 26*03ce13f7SAndroid Build Coastguard Worker namespace IceTest { 27*03ce13f7SAndroid Build Coastguard Worker 28*03ce13f7SAndroid Build Coastguard Worker // Class to run tests on Subzero's bitcode parser. Runs a Subzero 29*03ce13f7SAndroid Build Coastguard Worker // translation, using (possibly) edited bitcode record values. For 30*03ce13f7SAndroid Build Coastguard Worker // more details on how to represent the input arrays, see 31*03ce13f7SAndroid Build Coastguard Worker // NaClBitcodeMunge.h. 32*03ce13f7SAndroid Build Coastguard Worker class SubzeroBitcodeMunger : public llvm::NaClBitcodeMunger { 33*03ce13f7SAndroid Build Coastguard Worker public: SubzeroBitcodeMunger(const uint64_t Records[],size_t RecordSize,uint64_t RecordTerminator)34*03ce13f7SAndroid Build Coastguard Worker SubzeroBitcodeMunger(const uint64_t Records[], size_t RecordSize, 35*03ce13f7SAndroid Build Coastguard Worker uint64_t RecordTerminator) 36*03ce13f7SAndroid Build Coastguard Worker : llvm::NaClBitcodeMunger(Records, RecordSize, RecordTerminator) { 37*03ce13f7SAndroid Build Coastguard Worker resetMungeFlags(); 38*03ce13f7SAndroid Build Coastguard Worker } 39*03ce13f7SAndroid Build Coastguard Worker 40*03ce13f7SAndroid Build Coastguard Worker /// Runs PNaClTranslator to parse and (optionally) translate bitcode records 41*03ce13f7SAndroid Build Coastguard Worker /// (with defined record Munges), and puts output into DumpResults. Returns 42*03ce13f7SAndroid Build Coastguard Worker /// true if parse is successful. 43*03ce13f7SAndroid Build Coastguard Worker bool runTest(const uint64_t Munges[], size_t MungeSize, 44*03ce13f7SAndroid Build Coastguard Worker bool DisableTranslation = false); 45*03ce13f7SAndroid Build Coastguard Worker 46*03ce13f7SAndroid Build Coastguard Worker /// Same as above, but without any edits. 47*03ce13f7SAndroid Build Coastguard Worker bool runTest(bool DisableTranslation = false) { 48*03ce13f7SAndroid Build Coastguard Worker uint64_t NoMunges[] = {0}; 49*03ce13f7SAndroid Build Coastguard Worker return runTest(NoMunges, 0, DisableTranslation); 50*03ce13f7SAndroid Build Coastguard Worker } 51*03ce13f7SAndroid Build Coastguard Worker 52*03ce13f7SAndroid Build Coastguard Worker private: 53*03ce13f7SAndroid Build Coastguard Worker void resetMungeFlags(); 54*03ce13f7SAndroid Build Coastguard Worker }; 55*03ce13f7SAndroid Build Coastguard Worker 56*03ce13f7SAndroid Build Coastguard Worker } // end of namespace IceTest 57*03ce13f7SAndroid Build Coastguard Worker 58*03ce13f7SAndroid Build Coastguard Worker #endif // SUBZERO_UNITTEST_BITCODEMUNGE_H 59