WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

lib.rs 2.04 KB
Newer Older
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1
// Copyright 2017 The Australian National University
2
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
3 4 5
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
6
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
9 10 11 12 13 14
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

15 16 17
//! # MuIR AST crate
//!
//! This crate provides data structures to allow construct MuIR in Rust code, including:
qinsoon's avatar
qinsoon committed
18
//!
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
//! * types
//! * ir
//!   * MuFunction
//!   * MuFunctionVersion
//!     * FunctionContent
//!       * Block
//!         * BlockContent
//!           * TreeNode
//!             * Value
//!             * Instruction
//! * inst
//! * op (operators)
//!
//! Client should not create MuIR via this crate, use API instead.

34 35
#[macro_use]
extern crate rodal;
qinsoon's avatar
qinsoon committed
36
extern crate log;
qinsoon's avatar
qinsoon committed
37 38 39
extern crate simple_logger;
#[macro_use]
extern crate lazy_static;
qinsoon's avatar
qinsoon committed
40
extern crate mu_utils as utils;
qinsoon's avatar
qinsoon committed
41

42 43
/// all data structures for MuIR is an *MuEntity*
/// which has a unique MuID, and an optional MuName
qinsoon's avatar
qinsoon committed
44 45 46 47 48
#[macro_export]
macro_rules! impl_mu_entity {
    ($entity: ty) => {
        impl MuEntity for $entity {
            #[inline(always)]
49 50 51
            fn id(&self) -> MuID {
                self.hdr.id()
            }
qinsoon's avatar
qinsoon committed
52
            #[inline(always)]
53 54 55
            fn name(&self) -> MuName {
                self.hdr.name()
            }
qinsoon's avatar
qinsoon committed
56
            fn as_entity(&self) -> &MuEntity {
57
                let ref_ty: &$entity = self;
qinsoon's avatar
qinsoon committed
58 59 60
                ref_ty as &MuEntity
            }
        }
61
    };
qinsoon's avatar
qinsoon committed
62 63
}

64
/// select between two values based on condition
qinsoon's avatar
qinsoon committed
65 66 67 68 69 70 71
macro_rules! select_value {
    ($cond: expr, $res1 : expr, $res2 : expr) => {
        if $cond {
            $res1
        } else {
            $res2
        }
72
    };
qinsoon's avatar
qinsoon committed
73 74 75 76 77
}

#[macro_use]
pub mod ir;
pub mod inst;
78
pub mod op;
79 80
pub mod ptr;
pub mod types;