blob: a1a393d29760edbeedf30ac321ee1e0cf78b9f27 [file] [log] [blame]
Reid Spencerdac69c82004-06-07 17:53:43 +00001//===-- ReaderInternals.h - Definitions internal to the reader --*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This header file defines various stuff that is used by the bytecode reader.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef ANALYZER_INTERNALS_H
15#define ANALYZER_INTERNALS_H
16
Reid Spenceraee4f5b2004-06-08 05:52:29 +000017#include "ReaderPrimitives.h"
Reid Spencerdac69c82004-06-07 17:53:43 +000018#include "Parser.h"
19#include "llvm/Bytecode/Analyzer.h"
Reid Spenceraee4f5b2004-06-08 05:52:29 +000020#include "llvm/Constants.h"
21#include "llvm/DerivedTypes.h"
Reid Spencerdac69c82004-06-07 17:53:43 +000022
23// Enable to trace to figure out what the heck is going on when parsing fails
24//#define TRACE_LEVEL 10
25//#define DEBUG_OUTPUT
26
27#if TRACE_LEVEL // ByteCodeReading_TRACEr
28#define BCR_TRACE(n, X) \
29 if (n < TRACE_LEVEL) std::cerr << std::string(n*2, ' ') << X
30#else
31#define BCR_TRACE(n, X)
32#endif
33
34namespace llvm {
35
Reid Spenceraee4f5b2004-06-08 05:52:29 +000036inline void AbstractBytecodeParser::readBlock(const unsigned char *&Buf,
37 const unsigned char *EndBuf,
38 unsigned &Type, unsigned &Size)
39{
40 Type = read(Buf, EndBuf);
41 Size = read(Buf, EndBuf);
42}
43
Reid Spencerdac69c82004-06-07 17:53:43 +000044class BytecodeAnalyzer {
45 BytecodeAnalyzer(const BytecodeAnalyzer &); // DO NOT IMPLEMENT
46 void operator=(const BytecodeAnalyzer &); // DO NOT IMPLEMENT
47public:
48 BytecodeAnalyzer() { }
49 ~BytecodeAnalyzer() { }
50
51 void AnalyzeBytecode(
52 const unsigned char *Buf,
53 unsigned Length,
54 BytecodeAnalysis& bca,
55 const std::string &ModuleID
56 );
57
58 void DumpBytecode(
59 const unsigned char *Buf,
60 unsigned Length,
61 BytecodeAnalysis& bca,
62 const std::string &ModuleID
63 );
64
65 void dump() const {
66 std::cerr << "BytecodeParser instance!\n";
67 }
68private:
69 BytecodeAnalysis TheAnalysis;
70};
71
72} // End llvm namespace
73
74#endif
75
76// vim: sw=2