gcc config
[prop.git] / prop-src / bitfield.ph
blob3cbdd8a0c681884b6309d42aabf7ebd5d5a5ab0e
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 //  This file contains the definitions used in the bitfield and bitfield
4 //  pattern matcher/constraint solver.
5 //
6 ///////////////////////////////////////////////////////////////////////////////
7 #ifndef bitfields_and_bit_patterns_h
8 #define bitfields_and_bit_patterns_h
10 #include "ast.ph"
11 #include "codegen.h"
13 ///////////////////////////////////////////////////////////////////////////////
15 //  Definition of a field declaration
17 ///////////////////////////////////////////////////////////////////////////////
18 datatype FieldDef : Loc = 
19    FIELDdef     { field_name : Id,        // bitfield declaration
20                   from_bit   : int,
21                   to_bit     : int,
22                   is_signed  : Bool = false
23                 }
24 |  FIELDCONdef  { field_name : Id,        // bitfield constructor
25                   ty         : Ty
26                 }
27 and      FieldLaw : Loc = 
28    FIELDlaw     { id    : Id, 
29                   args  : Ids, 
30                   guard : Exp, 
31                   exp   : Exp 
32                 } 
35 ///////////////////////////////////////////////////////////////////////////////
36 //  The bitfield compiler is used to compile bitfield constructors
37 //  and patterns.
38 ///////////////////////////////////////////////////////////////////////////////
39 class BitfieldCompiler : virtual public CodeGen {
40    BitfieldCompiler (const BitfieldCompiler&);
41    void operator = (const BitfieldCompiler&);
42 public:
43             BitfieldCompiler();
44    virtual ~BitfieldCompiler();
46    ////////////////////////////////////////////////////////////////////////////
47    //  Methods to define and generate bitfield declarations.
48    ////////////////////////////////////////////////////////////////////////////
49    void define_bitfield (Id name, int width, FieldDefs, FieldLaws);
50    void gen_bitfield    (Id name, int width, FieldDefs, FieldLaws);
53 #endif