diff --git a/MiniC/Lib/Allocator.py b/MiniC/Lib/Allocator.py new file mode 100644 index 0000000..90fd460 --- /dev/null +++ b/MiniC/Lib/Allocator.py @@ -0,0 +1,79 @@ +""" +This file defines the base class :py:class:`Allocator` +and the naïve implementation :py:class:`NaiveAllocator`. +""" + +from Lib.Operands import Temporary, Operand, DataLocation, GP_REGS +from Lib.Statement import Instruction +from Lib.Errors import AllocationError +from Lib.FunctionData import FunctionData +from typing import Dict, List + + +class Allocator(): + """General base class for Naive, AllInMem and Smart Allocators. + Replace all temporaries in the code with actual data locations. + + Allocation is done in two steps: + + - First, :py:meth:`prepare` is responsible for calling + :py:meth:`Lib.Operands.TemporaryPool.set_temp_allocation` + with a mapping from temporaries to where they should actually be stored + (in registers or in memory). + - Then, :py:meth:`replace` is called for each instruction in order to + replace the temporary operands with the previously assigned locations + (and possibly add some instructions before or after). + Concretely, it returns a list of instructions that should replace the original + instruction. The actual iteration over all the instructions is handled transparently + by :py:meth:`Lib.LinearCode.LinearCode.iter_statements`. + """ + + _fdata: FunctionData + + def __init__(self, fdata: FunctionData): + self._fdata = fdata + + def prepare(self) -> None: # pragma: no cover + pass + + def replace(self, old_instr: Instruction) -> List[Instruction]: + """Transform an instruction with temporaries into a list of instructions.""" + return [old_instr] + + def rewriteCode(self, listcode) -> None: + """Modify the code to replace temporaries with + registers or memory locations. + """ + listcode.iter_statements(self.replace) + + +class NaiveAllocator(Allocator): + """Naive Allocator: try to assign a register to each temporary, + fails if there are more temporaries than registers. + """ + + def replace(self, old_instr: Instruction) -> List[Instruction]: + """Replace Temporary operands with the corresponding allocated Register.""" + new_args: List[Operand] = [] + for arg in old_instr.args(): + if isinstance(arg, Temporary): + new_args.append(arg.get_alloced_loc()) + else: + new_args.append(arg) + new_instr = old_instr.with_args(new_args) + return [new_instr] + + def prepare(self) -> None: + """Allocate all temporaries to registers. + Fail if there are too many temporaries.""" + regs = list(GP_REGS) # Get a writable copy + temp_allocation: Dict[Temporary, DataLocation] = dict() + for tmp in self._fdata._pool.get_all_temps(): + try: + reg = regs.pop() + except IndexError: + raise AllocationError( + "Too many temporaries ({}) for the naive allocation, sorry." + .format(len(self._fdata._pool.get_all_temps()))) + temp_allocation[tmp] = reg + self._fdata._pool.set_temp_allocation(temp_allocation) diff --git a/MiniC/Lib/CFG.py b/MiniC/Lib/CFG.py new file mode 100644 index 0000000..2553d9d --- /dev/null +++ b/MiniC/Lib/CFG.py @@ -0,0 +1,295 @@ +""" +Classes for a RiscV CFG: :py:class:`CFG` for the CFG itself, +and :py:class:`Block` for its basic blocks. +""" + +from graphviz import Digraph # for dot output +from typing import cast, Any, Dict, List, Set, Iterator + +from Lib.Errors import MiniCInternalError +from Lib.Operands import (Operand, Immediate, Function, A0) +from Lib.Statement import ( + Statement, Instru3A, Label, + AbsoluteJump, ConditionalJump, Comment +) +from Lib.Terminator import ( + Terminator, BranchingTerminator, Return) +from Lib.FunctionData import (FunctionData, _iter_statements, _print_code) + + +BlockInstr = Instru3A | Comment + + +class Block: + """ + A basic block of a :py:class:`CFG` is made of three main parts: + + - a start :py:class:`label ` that uniquely identifies the block in the CFG + - the main body of the block, a list of instructions + (excluding labels, jumps and branching instructions) + - a :py:class:`terminator ` + that represents the final jump or branching instruction of the block, + and points to the successors of the block. + See the documentation for :py:class:`Lib.Terminator.Terminator` for further explanations. + """ + + _terminator: Terminator + _label: Label + _phis: List[Statement] + _instructions: List[BlockInstr] + _in: List['Block'] + _gen: Set + _kill: Set + + def __init__(self, label: Label, insts: List[BlockInstr], terminator: Terminator): + self._label = label + self._instructions = insts + self._in = [] + self._phis = [] + self._terminator = terminator + self._gen = set() + self._kill = set() + + def __str__(self): + instr = [i for i in self._instructions if not isinstance(i, Comment)] + instr_str = '\n'.join(map(str, instr)) + s = '{}:\n\n{}'.format(self._label, instr_str) + return s + + def to_dot(self) -> str: # pragma: no cover + """Outputs all statements of the block as a string.""" + # dot is weird: lines ending with \l instead of \n are left-aligned. + NEWLINE = '\\l ' + instr = [] + instr += self._phis + instr += [i for i in self._instructions if not isinstance(i, Comment)] + instr += [self.get_terminator()] + instr_str = NEWLINE.join(map(str, instr)) + s = '{}:{}{}\\l'.format(self._label, NEWLINE, instr_str) + return s + + def __repr__(self): + return str(self._label) + + def get_body(self) -> List[BlockInstr]: + """Return the statements in the body of the block (no phi-node nor the terminator).""" + return self._instructions + + def get_all_statements(self) -> List[Statement]: + """ + Return all statements of the block + (including phi-nodes and the terminator, but not the label of the block). + """ + return (self._phis + + cast(List[Statement], self._instructions) + + [self.get_terminator()]) + + def get_body_and_terminator(self) -> List[Statement]: + """ + Return all statements of the block, except phi-nodes + (and the label of the block). + """ + return (cast(List[Statement], self._instructions) + + [self.get_terminator()]) + + def get_label(self) -> Label: + """Return the label of the block.""" + return self._label + + def get_in(self) -> List['Block']: + """Return the list of blocks with an edge to the considered block.""" + return self._in + + def get_terminator(self) -> Terminator: + """Return the terminator of the block.""" + return self._terminator + + def set_terminator(self, term: Terminator) -> None: + """Set the terminator of the block.""" + self._terminator = term + + def get_phis(self) -> List[Statement]: + """Return the list of all φ instructions of the block.""" + return self._phis + + def add_phi(self, phi: Statement) -> None: + """Add a φ instruction to the block.""" + self._phis.append(phi) + + def set_phis(self, phis: List[Statement]) -> None: + """Replace the φ instructions in the block by the given list `phis`.""" + self._phis = phis + + def remove_all_phis(self) -> None: + """Remove all φ instructions in the block.""" + self._phis = [] + + def iter_statements(self, f) -> None: + """Iterate over instructions. + For each real instruction i (not label or comment), replace it + with the list of instructions given by f(i). + + Assume there is no phi-node. + """ + assert (self._phis == []) + new_statements = _iter_statements(self._instructions, f) + end_statements = f(self.get_terminator()) + if len(end_statements) >= 1 and isinstance(end_statements[-1], Terminator): + new_terminator = end_statements.pop(-1) + self._instructions = new_statements + end_statements + self.set_terminator(new_terminator) + else: + raise MiniCInternalError( + "Block.iter_statements: Invalid replacement for terminator {}:\n {}" + .format(self.get_terminator(), end_statements)) + + def add_instruction(self, instr: BlockInstr) -> None: + """Add an instruction to the body of the block.""" + self._instructions.append(instr) + + +class CFG: + """ + A complete control-flow graph representing a function. + This class is mainly made of a list of basic :py:class:`Block`, + a label indicating the :py:meth:`entry point of the function `, + and an :py:meth:`exit label `. + + As with linear code, metadata about the function can be found + in the :py:attr:`fdata` member variable. + """ + + _start: Label + _end: Label + _blocks: Dict[Label, Block] + + #: Metadata about the function represented by this CFG + fdata: FunctionData + + def __init__(self, fdata: FunctionData): + self._blocks = {} + self.fdata = fdata + self._init_blks() + self._end = self.fdata.fresh_label("end") + + def _init_blks(self) -> None: + """Add a block for division by 0.""" + # Label for the address of the error message + # This address is added by print_code + label_div_by_zero_msg = Label(self.fdata._label_div_by_zero.name + "_msg") + blk = Block(self.fdata._label_div_by_zero, [ + Instru3A("la", A0, label_div_by_zero_msg), + Instru3A("call", Function("println_string")), + Instru3A("li", A0, Immediate(1)), + Instru3A("call", Function("exit")), + ], terminator=Return()) + self.add_block(blk) + + def get_start(self) -> Label: + """Return the entry label of the CFG.""" + return self._start + + def set_start(self, start: Label) -> None: + """Set the entry label of the CFG.""" + assert (start in self._blocks) + self._start = start + + def get_end(self) -> Label: + """Return the exit label of the CFG.""" + return self._end + + def add_block(self, blk: Block) -> None: + """Add a new block to the CFG.""" + self._blocks[blk._label] = blk + + def get_block(self, name: Label) -> Block: + """Return the block with label `name`.""" + return self._blocks[name] + + def get_blocks(self) -> List[Block]: + """Return all the blocks.""" + return [b for b in self._blocks.values()] + + def get_entries(self) -> List[Block]: + """Return all the blocks with no predecessors.""" + return [b for b in self._blocks.values() if not b.get_in()] + + def add_edge(self, src: Block, dest: Block) -> None: + """Add the edge src -> dest in the control flow graph.""" + dest.get_in().append(src) + # assert (dest.get_label() in src.get_terminator().targets()) + + def remove_edge(self, src: Block, dest: Block) -> None: + """Remove the edge src -> dest in the control flow graph.""" + dest.get_in().remove(src) + # assert (dest.get_label() not in src.get_terminator().targets()) + + def out_blocks(self, block: Block) -> List[Block]: + """ + Return the list of blocks in the CFG targeted by + the Terminator of Block block. + """ + return [self.get_block(dest) for dest in block.get_terminator().targets()] + + def gather_defs(self) -> Dict[Any, Set[Block]]: + """ + Return a dictionary associating variables to all the blocks + containing one of their definitions. + """ + defs: Dict[Operand, Set[Block]] = dict() + for b in self.get_blocks(): + for i in b.get_all_statements(): + for v in i.defined(): + if v not in defs: + defs[v] = {b} + else: + defs[v].add(b) + return defs + + def iter_statements(self, f) -> None: + """Apply f to all instructions in all the blocks.""" + for b in self.get_blocks(): + b.iter_statements(f) + + def linearize_naive(self) -> Iterator[Statement]: + """ + Linearize the given control flow graph as a list of instructions. + Naive procedure that adds jumps everywhere. + """ + for label, block in self._blocks.items(): + yield label + for i in block._instructions: + yield i + match block.get_terminator(): + case BranchingTerminator() as j: + # In case of conditional jump, add the missing edge + yield ConditionalJump(j.cond, j.op1, j.op2, j.label_then) + yield AbsoluteJump(j.label_else) + case AbsoluteJump() as j: + yield AbsoluteJump(j.label) + case Return(): + yield AbsoluteJump(self.get_end()) + + def print_code(self, output, linearize=(lambda cfg: list(cfg.linearize_naive())), + comment=None) -> None: + """Print the linearization of the CFG.""" + statements = linearize(self) + _print_code(statements, self.fdata, output, init_label=self._start, + fin_label=self._end, fin_div0=False, comment=comment) + + def print_dot(self, filename, DF=None, view=False) -> None: # pragma: no cover + """Print the CFG as a graph.""" + graph = Digraph() + # nodes + for name, blk in self._blocks.items(): + if DF is not None: + df_str = "{}" if blk not in DF or not len(DF[blk]) else str(DF[blk]) + df_lab = blk.to_dot() + "\n\nDominance frontier:\n" + df_str + else: + df_lab = blk.to_dot() + graph.node(str(blk._label), label=df_lab, shape='rectangle') + # edges + for name, blk in self._blocks.items(): + for child in blk.get_terminator().targets(): + graph.edge(str(blk._label), str(child)) + graph.render(filename, view=view) diff --git a/MiniC/Lib/Dominators.py b/MiniC/Lib/Dominators.py new file mode 100644 index 0000000..71fffe0 --- /dev/null +++ b/MiniC/Lib/Dominators.py @@ -0,0 +1,128 @@ +""" +Utility functions to work with dominators in a :py:class:`CFG `. + +Do not hesitate to look at the source of the functions +to get a better understanding of the algorithms. +""" + +from typing import Dict, Set +from graphviz import Digraph +from Lib.CFG import Block, CFG + + +def computeDom(cfg: CFG) -> Dict[Block, Set[Block]]: + """ + `computeDom(cfg)` computes the table associating blocks to their + dominators in `cfg`. + It works by solving the equation system. + + This is an helper function called during SSA entry. + """ + all_blocks: Set[Block] = set(cfg.get_blocks()) + dominators: Dict[Block, Set[Block]] = dict() + for b in all_blocks: + if b.get_in(): # If b has some predecessor + dominators[b] = all_blocks + else: # If b has no predecessors + dominators[b] = {b} + new_dominators: Dict[Block, Set[Block]] = dict() + while True: + for b in all_blocks: + if b.get_in(): + dom_preds = [dominators[b2] for b2 in b.get_in()] + new_dominators[b] = {b}.union(set.intersection(*dom_preds)) + else: + new_dominators[b] = {b} + if dominators == new_dominators: + break + else: + dominators = new_dominators + new_dominators = dict() + return dominators + + +def printDT(filename: str, graph: Dict[Block, Set[Block]]) -> None: # pragma: no cover + """Display a graphical rendering of the given domination tree.""" + dot = Digraph() + for k in graph: + dot.node(str(k.get_label())) + for k in graph: + for v in graph[k]: + dot.edge(str(k.get_label()), str(v.get_label())) + dot.render(filename, view=True) + + +def computeDT(cfg: CFG, dominators: Dict[Block, Set[Block]], + dom_graphs: bool, basename: str) -> Dict[Block, Set[Block]]: + """ + `computeDT(cfg, dominators)` computes the domination tree of `cfg` + using the previously computed `dominators`. + It returns `DT`, a dictionary which associates a block with its children + in the dominator tree. + + This is an helper function called during SSA entry. + """ + # First, compute the immediate dominators + idominators: Dict[Block, Block] = {} + for b, doms in dominators.items(): + # The immediate dominator of b is the unique vertex n ≠ b + # which dominates b and is dominated by all vertices in Dom(b) − b. + strict_doms = doms - {b} + idoms = set() + for n in strict_doms: + if strict_doms.issubset(dominators[n]): + idoms.add(n) + if idoms: + assert (len(idoms) == 1) + idominators[b] = idoms.pop() + # Then, simply inverse the relation to obtain the domination tree + DT = {b: set() for b in cfg.get_blocks()} + for i, idominator in idominators.items(): + DT[idominator].add(i) + # Print the domination tree if asked + if dom_graphs: + s = "{}.{}.ssa.DT.dot".format(basename, cfg.fdata.get_name()) + print("SSA - domination tree graph:", s) + printDT(s, DT) + return DT + + +def _computeDF_at_block( + cfg: CFG, + dominators: Dict[Block, Set[Block]], + DT: Dict[Block, Set[Block]], + b: Block, + DF: Dict[Block, Set[Block]]) -> None: + """ + `_computeDF_at_block(...)` computes the dominance frontier at the given block, + by updating `DF`. + + This is an helper function called during SSA entry. + """ + S: Set[Block] = {succ for succ in cfg.out_blocks(b) if succ not in DT[b]} + for b_succ in DT[b]: + _computeDF_at_block(cfg, dominators, DT, b_succ, DF) + for b_frontier in DF[b_succ]: + if b not in (dominators[b_frontier] - {b_frontier}): + S.add(b_frontier) + DF[b] = S + + +def computeDF(cfg: CFG, dominators: Dict[Block, Set[Block]], + DT: Dict[Block, Set[Block]], dom_graphs: bool, basename: str + ) -> Dict[Block, Set[Block]]: + """ + `computeDF(...)` computes the dominance frontier of a CFG. + It returns `DF` which associates a block to its frontier. + + This is an helper function called during SSA entry. + """ + DF: Dict[Block, Set[Block]] = dict() + for b_entry in cfg.get_entries(): + _computeDF_at_block(cfg, dominators, DT, b_entry, DF) + # Print the domination frontier on the CFG if asked + if dom_graphs: + s = "{}.{}.ssa.DF.dot".format(basename, cfg.fdata.get_name()) + print("SSA - dominance frontier graph:", s) + cfg.print_dot(s, DF, True) + return DF diff --git a/MiniC/Lib/FunctionData.py b/MiniC/Lib/FunctionData.py new file mode 100644 index 0000000..9a0820d --- /dev/null +++ b/MiniC/Lib/FunctionData.py @@ -0,0 +1,181 @@ +""" +This file defines the base class :py:class:`FunctionData`, +containing metadata on a RiscV function, as well as utility +functions common to the different intermediate representations. +""" + +from typing import (List, Callable, TypeVar) +from Lib.Errors import AllocationError +from Lib.Operands import ( + Offset, Temporary, TemporaryPool, + S, T, FP) +from Lib.Statement import (Statement, Instruction, Label, Comment) + + +class FunctionData: + """ + Stores some metadata on a RiscV function: + name of the function, label names, temporary variables + (using :py:class:`Lib.Operands.TemporaryPool`), + and div_by_zero label. + + This class is usually used indirectly through the + different intermediate representations we work with, + such as :py:attr:`Lib.LinearCode.LinearCode.fdata`. + """ + + _nblabel: int + _dec: int + _pool: TemporaryPool + _name: str + _label_div_by_zero: Label + + def __init__(self, name: str): + self._nblabel = -1 + self._dec = 0 + self._pool = TemporaryPool() + self._name = name + self._label_div_by_zero = self.fresh_label("div_by_zero") + + def get_name(self) -> str: + """Return the name of the function.""" + return self._name + + def fresh_tmp(self) -> Temporary: + """ + Return a new fresh Temporary, + which is added to the pool. + """ + return self._pool.fresh_tmp() + + def fresh_offset(self) -> Offset: + """ + Return a new offset in the memory stack. + Offsets are decreasing relative to FP. + """ + self._dec = self._dec + 1 + # For ld or sd, an offset on 12 signed bits is expected + # Raise an error if the offset is too big + if -8 * self._dec < - 2 ** 11: + raise AllocationError( + "Offset given by the allocation too big to be manipulated ({}), sorry." + .format(self._dec)) + return Offset(FP, -8 * self._dec) + + def get_offset(self) -> int: + """ + Return the current offset in the memory stack. + """ + return self._dec + + def _fresh_label_name(self, name) -> str: + """ + Return a new unique label name based on the given string. + """ + self._nblabel = self._nblabel + 1 + return name + "_" + str(self._nblabel) + "_" + self._name + + def fresh_label(self, name) -> Label: + """ + Return a new label, with a unique name based on the given string. + """ + return Label(self._fresh_label_name(name)) + + def get_label_div_by_zero(self) -> Label: + return self._label_div_by_zero + + +_T = TypeVar("_T", bound=Statement) + + +def _iter_statements( + listIns: List[_T], f: Callable[[_T], List[_T]]) -> List[_T | Comment]: + """Iterate over instructions. + For each real instruction i (not label or comment), replace it + with the list of instructions given by f(i). + """ + newListIns: List[_T | Comment] = [] + for old_i in listIns: + # Do nothing for label or comment + if not isinstance(old_i, Instruction): + newListIns.append(old_i) + continue + new_i_list = f(old_i) + # Otherwise, replace the instruction by the list + # returned by f, with comments giving the replacement + newListIns.append(Comment("Replaced " + str(old_i))) + newListIns.extend(new_i_list) + return newListIns + + +def _print_code(listIns: List, fdata: FunctionData, output, + init_label=None, fin_label=None, fin_div0=False, comment=None) -> None: + """ + Please use print_code from LinearCode or CFG, not directly this one. + + Print the instructions from listIns, forming fdata, on output. + If init_label is given, add an initial jump to it before the generated code. + If fin_label is given, add it after the generated code. + If fin_div0 is given equal to true, add the code for returning an + error when dividing by 0, at the very end. + """ + # compute size for the local stack - do not forget to align by 16 + fo = fdata.get_offset() # allocate enough memory for stack + # Room for S_i (except S_0 which is fp) and T_i backup + fo += len(S[1:]) + len(T) + cardoffset = 8 * (fo + (0 if fo % 2 == 0 else 1)) + 16 + output.write( + "##Automatically generated RISCV code, MIF08 & CAP\n") + if comment is not None: + output.write("##{} version\n".format(comment)) + output.write("\n\n##prelude\n") + # We put an li t0, cardoffset in case it is greater than 2**11 + # We use t0 because it is caller-saved + output.write(""" + .text + .globl {0} +{0}: + li t0, {1} + sub sp, sp, t0 + sd ra, 0(sp) + sd fp, 8(sp) + add fp, sp, t0 +""".format(fdata.get_name(), cardoffset)) + # Stack in RiscV is managed with SP + if init_label is not None: + # Add a jump to init_label before the generated code. + output.write(""" + j {0} +""".format(init_label)) + output.write("\n\n##Generated Code\n") + # Generated code + for i in listIns: + i.printIns(output) + output.write("\n\n##postlude\n") + if fin_label is not None: + # Add fin_label after the generated code. + output.write(""" +{0}: +""".format(fin_label)) + # We put an li t0, cardoffset in case it is greater than 2**11 + # We use t0 because it is caller-saved + output.write(""" + ld ra, 0(sp) + ld fp, 8(sp) + li t0, {0} + add sp, sp, t0 + ret +""".format(cardoffset)) + if fin_div0: + # Add code for division by 0 at the end. + output.write(""" +{0}: + la a0, {0}_msg + call println_string + li a0, 1 + call exit +""".format(fdata._label_div_by_zero)) + # Add the data for the message of the division by 0 + output.write(""" +{0}_msg: .string "Division by 0" +""".format(fdata._label_div_by_zero)) diff --git a/MiniC/Lib/Graphes.py b/MiniC/Lib/Graphes.py new file mode 100644 index 0000000..22124dc --- /dev/null +++ b/MiniC/Lib/Graphes.py @@ -0,0 +1,312 @@ +""" Python Classes for Oriented and Non Oriented Graphs +""" + +from graphviz import Digraph # for dot output +from typing import List, Dict, Set, Tuple, Any + + +class GraphError(Exception): + """Exception raised for self loops. + """ + + message: str + + def __init__(self, message: str): + self.message = message + + +class GeneralGraph(object): + """ + General class regrouping similarities + between directed and non oriented graphs. + The only differences between the two are: + + - how to compute the set of edges + - how to add an edge + - how to print the graph + - how to delete a vertex + - how to delete an edge + - we only color undirected graphs + """ + + graph_dict: Dict[Any, Set] + + def __init__(self, graph_dict=None): + """ + Initializes a graph object. + If no dictionary or None is given, + an empty dictionary will be used. + """ + if graph_dict is None: + graph_dict = {} + self.graph_dict = graph_dict + + def vertices(self) -> List[Any]: + """Return the vertices of a graph.""" + return list(self.graph_dict.keys()) + + def add_vertex(self, vertex: Any) -> None: + """ + If the vertex "vertex" is not in + self.graph_dict, a key "vertex" with an empty + list as a value is added to the dictionary. + Otherwise nothing has to be done. + """ + if vertex not in self.graph_dict: + self.graph_dict[vertex] = set() + + def edges(self) -> List[Set]: + """Return the edges of the graph.""" + return [] + + def __str__(self): + res = "vertices: " + for k in self.graph_dict: + res += str(k) + " " + res += "\nedges: " + for edge in self.edges(): + res += str(edge) + " " + return res + + def dfs_traversal(self, root: Any) -> List[Any]: + """ + Compute a depth first search of the graph, + from the vertex root. + """ + seen: List[Any] = [] + todo: List[Any] = [root] + while len(todo) > 0: # while todo ... + current = todo.pop() + seen.append(current) + for neighbour in self.graph_dict[current]: + if neighbour not in seen: + todo.append(neighbour) + return seen + + def is_reachable_from(self, v1: Any, v2: Any) -> bool: + """True if there is a path from v1 to v2.""" + return v2 in self.dfs_traversal(v1) + + def connected_components(self) -> List[List[Any]]: + """ + Compute the list of all connected components of the graph, + each component being a list of vetices. + """ + components: List[List[Any]] = [] + done: List[Any] = [] + for v in self.vertices(): + if v not in done: + v_comp = self.dfs_traversal(v) + components.append(v_comp) + done.extend(v_comp) + return components + + def bfs_traversal(self, root: Any) -> List[Any]: + """ + Compute a breadth first search of the graph, + from the vertex root. + """ + seen: List[Any] = [] + todo: List[Any] = [root] + while len(todo) > 0: # while todo ... + current = todo.pop(0) # list.pop(0): for dequeuing (on the left...) ! + seen.append(current) + for neighbour in self.graph_dict[current]: + if neighbour not in seen: + todo.append(neighbour) + return seen + + +class Graph(GeneralGraph): + """Class for non oriented graphs.""" + + def edges(self) -> List[Set]: + """ + A static method generating the set of edges + (they appear twice in the dictionnary). + Return a list of sets. + """ + edges = [] + for vertex in self.graph_dict: + for neighbour in self.graph_dict[vertex]: + if {neighbour, vertex} not in edges: + edges.append({vertex, neighbour}) + return edges + + def add_edge(self, edge: Tuple[Any, Any]) -> None: + """ + Add an edge in the graph. + edge should be a pair and not (c,c) + (we call g.add_edge((v1,v2))) + """ + (vertex1, vertex2) = edge + if vertex1 == vertex2: + raise GraphError("Cannot add a self loop on vertex {} in an unoriented graph.".format( + str(vertex1))) + if vertex1 in self.graph_dict: + self.graph_dict[vertex1].add(vertex2) + else: + self.graph_dict[vertex1] = {vertex2} + if vertex2 in self.graph_dict: + self.graph_dict[vertex2].add(vertex1) + else: + self.graph_dict[vertex2] = {vertex1} + + def print_dot(self, name: str, colors={}) -> None: + """Print the graph.""" + color_names = ['red', 'blue', 'green', 'yellow', 'cyan', 'magenta'] + \ + [f"grey{i}" for i in range(0, 100, 10)] + color_shapes = ['ellipse', 'box', 'diamond', 'trapezium', 'egg', + 'parallelogram', 'house', 'triangle', 'pentagon', 'hexagon', + 'septagon', 'octagon'] + dot = Digraph(comment='Conflict Graph') + for k in self.graph_dict: + shape = None + if not colors: + color = "red" # Graph not colored: red for everyone + elif k not in colors: + color = "grey" # Node not colored: grey + else: + n = colors[k] + if n < len(color_names): + color = color_names[colors[k]] + else: + color = "black" # Too many colors anyway, it won't be readable. + shape = color_shapes[n % len(color_shapes)] + dot.node(str(k), color=color, shape=shape) + for (v1, v2) in self.edges(): + dot.edge(str(v1), str(v2), dir="none") + # print(dot.source) + dot.render(name, view=True) # print in pdf + + def delete_vertex(self, vertex: Any) -> None: + """Delete a vertex and all the adjacent edges.""" + gdict = self.graph_dict + for neighbour in gdict[vertex]: + gdict[neighbour].remove(vertex) + del gdict[vertex] + + def delete_edge(self, edge: Tuple[Any, Any]): + """Delete an edge.""" + (v1, v2) = edge + self.graph_dict[v1].remove(v2) + self.graph_dict[v2].remove(v1) + + def color(self) -> Dict[Any, int]: + """ + Color the graph with an unlimited number of colors. + Return a dict vertex -> color, where color is an integer (0, 1, ...). + """ + coloring, _, _ = self.color_with_k_colors() + return coloring + + # see algo of the course + def color_with_k_colors(self, K=None, avoidingnodes=()) -> Tuple[Dict[Any, int], bool, List]: + """ + Color with <= K colors (if K is unspecified, use unlimited colors). + + Return 3 values: + + - a dict vertex -> color + - a Boolean, True if the coloring succeeded + - the set of nodes actually colored + + Do not color vertices belonging to avoidingnodes. + + Continue even if the algo fails. + """ + if K is None: + K = len(self.graph_dict) + todo_vertices = [] + is_total = True + gcopy = Graph(self.graph_dict.copy()) + # suppress nodes that are not to be considered. + for node in avoidingnodes: + gcopy.delete_vertex(node) + # append nodes in the list according to their degree and node number: + while gcopy.graph_dict: + todo = list(gcopy.graph_dict) + todo.sort(key=lambda v: (len(gcopy.graph_dict[v]), str(v))) + lower = todo[0] + todo_vertices.append(lower) + gcopy.delete_vertex(lower) + # Now reverse the list: first elements are those with higher degree + # print(todo_vertices) + todo_vertices.reverse() # in place reversal + # print(todo_vertices) + coloring = {} + colored_nodes = [] + # gdict will be the coloring map to return + gdict = self.graph_dict + for v in todo_vertices: + seen_neighbours = [x for x in gdict[v] if x in coloring] + choose_among = [i for i in range(K) if not ( + i in [coloring[v1] for v1 in seen_neighbours])] + if choose_among: + # if the node can be colored, I choose the minimal color. + color = min(choose_among) + coloring[v] = color + colored_nodes.append(v) + else: + # if I cannot color some node, the coloring is not Total + # but I continue + is_total = False + return (coloring, is_total, colored_nodes) + + +class DiGraph(GeneralGraph): + """Class for directed graphs.""" + + def pred(self, v: Any) -> Set: + """Return all predecessors of the vertex `v` in the graph.""" + return {src for src, dests in self.graph_dict.items() if v in dests} + + def neighbourhoods(self) -> List[Tuple[Any, Set]]: + """Return all neighbourhoods in the graph.""" + return list(self.graph_dict.items()) + + def edges(self) -> List[Set]: + """ A static method generating the set of edges""" + edges = [] + for vertex in self.graph_dict: + for neighbour in self.graph_dict[vertex]: + edges.append((vertex, neighbour)) + return edges + + def add_edge(self, edge: Tuple[Any, Any]) -> None: + """ + Add an edge in the graph. + edge should be a pair and not (c,c) + (we call g.add_edge((v1,v2))) + """ + (vertex1, vertex2) = edge + if vertex1 in self.graph_dict: + self.graph_dict[vertex1].add(vertex2) + else: + self.graph_dict[vertex1] = {vertex2} + if vertex2 not in self.graph_dict: + self.graph_dict[vertex2] = set() + + def print_dot(self, name: str) -> None: + """Print the graph.""" + dot = Digraph(comment='Conflict Graph') + for k in self.graph_dict: + shape = None + color = "grey" + dot.node(str(k), color=color, shape=shape) + for (v1, v2) in self.edges(): + dot.edge(str(v1), str(v2), dir="none") + # print(dot.source) + dot.render(name, view=True) # print in pdf + + def delete_vertex(self, vertex: Any) -> None: + """Delete a vertex and all the adjacent edges.""" + for node, neighbours in self.graph_dict.items(): + if vertex in neighbours: + neighbours.remove(vertex) + del self.graph_dict[vertex] + + def delete_edge(self, edge: Tuple[Any, Any]) -> None: + """Delete an edge.""" + (v1, v2) = edge + self.graph_dict[v1].remove(v2) diff --git a/MiniC/Lib/LinearCode.py b/MiniC/Lib/LinearCode.py new file mode 100644 index 0000000..dbadcb2 --- /dev/null +++ b/MiniC/Lib/LinearCode.py @@ -0,0 +1,103 @@ +""" +CAP, CodeGeneration, LinearCode API +Classes for a RiscV linear code. +""" + +from typing import List +from Lib.Operands import (A0, Function, DataLocation) +from Lib.Statement import ( + Instru3A, AbsoluteJump, ConditionalJump, Comment, Label +) +from Lib.RiscV import (mv, call) +from Lib.FunctionData import (FunctionData, _iter_statements, _print_code) + + +CodeStatement = Comment | Label | Instru3A | AbsoluteJump | ConditionalJump + + +class LinearCode: + """ + Representation of a RiscV program as a list of instructions. + + :py:meth:`add_instruction` is repeatedly called in the codegen visitor + to build a complete list of RiscV instructions for the source program. + + The :py:attr:`fdata` member variable contains some meta-information + on the program, for instance to allocate a new temporary. + See :py:class:`Lib.FunctionData.FunctionData`. + + For debugging purposes, :py:meth:`print_code` allows to print + the RiscV program to a file. + """ + + """ + The :py:attr:`fdata` member variable contains some meta-information + on the program, for instance to allocate a new temporary. + See :py:class:`Lib.FunctionData.FunctionData`. + """ + fdata: FunctionData + + _listIns: List[CodeStatement] + + def __init__(self, name: str): + self._listIns = [] + self.fdata = FunctionData(name) + + def add_instruction(self, i: CodeStatement) -> None: + """ + Utility function to add an instruction in the program. + + See also :py:mod:`Lib.RiscV` to generate relevant instructions. + """ + self._listIns.append(i) + + def iter_statements(self, f) -> None: + """Iterate over instructions. + For each real instruction i (not label or comment), replace it + with the list of instructions given by f(i). + """ + new_list_ins = _iter_statements(self._listIns, f) + # TODO: we shoudn't need to split this assignment with intermediate + # variable new_list_ins, but at least pyright pyright 1.1.293 + # raises an error here if we don't. + self._listIns = new_list_ins + + def get_instructions(self) -> List[CodeStatement]: + """Return the list of instructions of the program.""" + return self._listIns + + # each instruction has its own "add in list" version + def add_label(self, s: Label) -> None: + """Add a label in the program.""" + return self.add_instruction(s) + + def add_comment(self, s: str) -> None: + """Add a comment in the program.""" + self.add_instruction(Comment(s)) + + def add_instruction_PRINTLN_INT(self, reg: DataLocation) -> None: + """Print integer value, with newline. (see Expand)""" + # A print instruction generates the temp it prints. + self.add_instruction(mv(A0, reg)) + self.add_instruction(call(Function('println_int'))) + + def __str__(self): + return '\n'.join(map(str, self._listIns)) + + def print_code(self, output, comment=None) -> None: + """Outputs the RiscV program as text to a file at the given path.""" + _print_code(self._listIns, self.fdata, output, init_label=None, + fin_label=None, fin_div0=True, comment=comment) + + def print_dot(self, filename: str, DF=None, view=False) -> None: # pragma: no cover + """Outputs the RiscV program as graph to a file at the given path.""" + # import graphviz here so that students who don't have it can still work on lab4 + from graphviz import Digraph + graph = Digraph() + # nodes + content = "" + for i in self._listIns: + content += str(i) + "\\l" + graph.node("Code", label=content, shape='rectangle') + # no edges + graph.render(filename, view=view) diff --git a/MiniC/Lib/Operands.py b/MiniC/Lib/Operands.py new file mode 100644 index 0000000..08d66b3 --- /dev/null +++ b/MiniC/Lib/Operands.py @@ -0,0 +1,279 @@ +""" +This file defines the base class :py:class:`Operand` +and its subclasses for different operands: :py:class:`Condition`, +:py:class:`DataLocation` and :py:class:`Function`. + +The class :py:class:`DataLocation` itself has subclasses: +:py:class:`Register`, :py:class:`Offset` for address in memory, +:py:class:`Immediate` for constants and :py:class:`Temporary` +for location not yet allocated. + +This file also define shortcuts for registers in RISCV. +""" + +from typing import Dict, List +from MiniCParser import MiniCParser +from Lib.Errors import MiniCInternalError + + +class Operand(): + + pass + + +# signed version for riscv +all_ops = ['blt', 'bgt', 'beq', 'bne', 'ble', 'bge', 'beqz', 'bnez'] +opdict = {MiniCParser.LT: 'blt', MiniCParser.GT: 'bgt', + MiniCParser.LTEQ: 'ble', MiniCParser.GTEQ: 'bge', + MiniCParser.NEQ: 'bne', MiniCParser.EQ: 'beq'} +opnot_dict = {'bgt': 'ble', + 'bge': 'blt', + 'blt': 'bge', + 'ble': 'bgt', + 'beq': 'bne', + 'bne': 'beq', + 'beqz': 'bnez', + 'bnez': 'beqz'} + + +class Condition(Operand): + """Condition, i.e. comparison operand for a CondJump. + + Example usage : + + - Condition('beq') = branch if equal. + - Condition(MiniCParser.LT) = branch if lower than. + - ... + + The constructor's argument shall be a string in the list all_ops, or a + comparison operator in MiniCParser.LT, MiniCParser.GT, ... (one of the keys + in opdict). + + A 'negate' method allows getting the negation of this condition. + """ + + _op: str + + def __init__(self, optype): + if optype in opdict: + self._op = opdict[optype] + elif str(optype) in all_ops: + self._op = str(optype) + else: + raise MiniCInternalError(f"Unsupported comparison operator {optype}") + + def negate(self) -> 'Condition': + """Return the opposite condition.""" + return Condition(opnot_dict[self._op]) + + def __str__(self): + return self._op + + +class Function(Operand): + """Operand for build-in function call.""" + + _name: str + + def __init__(self, name: str): + self._name = name + + def __str__(self): + return self._name + + +class DataLocation(Operand): + """ A Data Location is either a register, a temporary + or a place in memory (offset). + """ + + pass + + +# map for register shortcuts +reg_map = dict([(0, 'zero'), (1, 'ra'), (2, 'sp')] + # no (3, 'gp') nor (4, 'tp') + [(i+5, 't'+str(i)) for i in range(3)] + + [(8, 'fp'), (9, 's1')] + + [(i+10, 'a'+str(i)) for i in range(8)] + + [(i+18, 's'+str(i+2)) for i in range(10)] + + [(i+28, 't'+str(i+3)) for i in range(4)]) + + +class Register(DataLocation): + """ A (physical) register.""" + + _number: int + + def __init__(self, number: int): + self._number = number + + def __repr__(self): + if self._number not in reg_map: + raise MiniCInternalError(f"Register number {self._number} should not be used") + else: + return ("{}".format(reg_map[self._number])) + + def __eq__(self, other): + return isinstance(other, Register) and self._number == other._number + + def __hash__(self): + return self._number + + +# Shortcuts for registers in RISCV +# Only integer registers + +#: Zero register +ZERO = Register(0) +#: +RA = Register(1) +#: +SP = Register(2) +#: Register not used for this course +GP = Register(3) +#: Register not used for this course +TP = Register(4) +#: +A = tuple(Register(i + 10) for i in range(8)) +#: +S = tuple(Register(i + 8) for i in range(2)) + tuple(Register(i + 18) for i in range(10)) +#: +T = tuple(Register(i + 5) for i in range(3)) + tuple(Register(i + 28) for i in range(4)) + + +#: +A0 = A[0] # function args/return Values: A0, A1 +#: +A1 = A[1] +#: Frame Pointer = Saved register 0 +FP = S[0] + +#: General purpose registers, usable for the allocator +GP_REGS = S[4:] + T # s0, s1, s2 and s3 are special + + +class Offset(DataLocation): + """ Offset = address in memory computed with base + offset.""" + + _basereg: Register + _offset: int + + def __init__(self, basereg: Register, offset: int): + self._basereg = basereg + self._offset = offset + + def __repr__(self): + return ("{}({})".format(self._offset, self._basereg)) + + def get_offset(self) -> int: + """Return the value of the offset.""" + return self._offset + + +class Immediate(DataLocation): + """Immediate operand (integer).""" + + _val: int + + def __init__(self, val): + self._val = val + + def __str__(self): + return str(self._val) + + +class Temporary(DataLocation): + """Temporary, a location that has not been allocated yet. + It will later be mapped to a physical register (Register) or to a memory location (Offset). + """ + + _number: int + _pool: 'TemporaryPool' + + def __init__(self, number: int, pool: 'TemporaryPool'): + self._number = number + self._pool = pool + + def __repr__(self): + return ("temp_{}".format(str(self._number))) + + def get_alloced_loc(self) -> DataLocation: + """Return the DataLocation allocated to this Temporary.""" + return self._pool.get_alloced_loc(self) + + +class TemporaryPool: + """Manage a pool of temporaries.""" + + _all_temps: List[Temporary] + _current_num: int + _allocation: Dict[Temporary, DataLocation] + + def __init__(self): + self._all_temps = [] + self._current_num = 0 + self._allocation = dict() + + def get_all_temps(self) -> List[Temporary]: + """Return all the temporaries of the pool.""" + return self._all_temps + + def get_alloced_loc(self, t: Temporary) -> DataLocation: + """Get the actual DataLocation allocated for the temporary t.""" + return self._allocation[t] + + def add_tmp(self, t: Temporary): + """Add a temporary to the pool.""" + self._all_temps.append(t) + self._allocation[t] = t # While no allocation, return the temporary itself + + def set_temp_allocation(self, allocation: Dict[Temporary, DataLocation]) -> None: + """Give a mapping from temporaries to actual registers. + The argument allocation must be a dict from Temporary to + DataLocation other than Temporary (typically Register or Offset). + Typing enforces that keys are Temporary and values are Datalocation. + We check the values are indeed not Temporary. + """ + for v in allocation.values(): + assert not isinstance(v, Temporary), ( + "Incorrect allocation scheme: value " + + str(v) + " is a Temporary.") + self._allocation = allocation + + def fresh_tmp(self) -> Temporary: + """Give a new fresh Temporary and add it to the pool.""" + t = Temporary(self._current_num, self) + self._current_num += 1 + self.add_tmp(t) + return t + + +class Renamer: + """Manage a renaming of temporaries.""" + + _pool: TemporaryPool + _env: Dict[Temporary, Temporary] + + def __init__(self, pool: TemporaryPool): + self._pool = pool + self._env = dict() + + def fresh(self, t: Temporary) -> Temporary: + """Give a fresh rename for a Temporary.""" + new_t = self._pool.fresh_tmp() + self._env[t] = new_t + return new_t + + def replace(self, t: Temporary) -> Temporary: + """Give the rename for a Temporary (which is itself if it is not renamed).""" + return self._env.get(t, t) + + def defined(self, t: Temporary) -> bool: + """True if the Temporary is renamed.""" + return t in self._env + + def copy(self): + """Give a copy of the Renamer.""" + r = Renamer(self._pool) + r._env = self._env.copy() + return r diff --git a/MiniC/Lib/PhiNode.py b/MiniC/Lib/PhiNode.py new file mode 100644 index 0000000..0cb5b55 --- /dev/null +++ b/MiniC/Lib/PhiNode.py @@ -0,0 +1,62 @@ +""" +Classes for φ nodes in a RiscV CFG :py:class:`CFG ` under SSA Form: +:py:class:`PhiNode` for a statement of the form temp_x = φ(temp_0, ..., temp_n). +These particular kinds of statements are expected to be in the field +b._phis for a :py:class:`Block ` b. +""" + +from dataclasses import dataclass +from typing import List, Dict + +from Lib.Operands import Operand, Temporary, DataLocation, Renamer +from Lib.Statement import Statement, Label + + +@dataclass +class PhiNode(Statement): + """ + A φ node is a renaming in the CFG, of the form temp_x = φ(temp_0, ..., temp_n). + The field var contains the variable temp_x. + The field srcs relies for each precedent block in the CFG, identified with its label, + the variable temp_i of the φ node. + """ + var: DataLocation + srcs: Dict[Label, Operand] + + def defined(self) -> List[Operand]: + """Return the variable defined by the φ node.""" + return [self.var] + + def get_srcs(self) -> Dict[Label, Operand]: + """ + Return the dictionnary associating for each previous block the corresponding variable. + """ + return self.srcs + + def used(self) -> List[Operand]: + """Return the variables used by the statement.""" + return list(self.srcs.values()) + + def rename(self, renamer: Renamer) -> None: + """Rename the variable defined by the φ node with a fresh name.""" + if isinstance(self.var, Temporary): + self.var = renamer.fresh(self.var) + + def rename_from(self, renamer: Renamer, label: Label) -> None: + """Rename the variable associated to the block identified by `label`.""" + if label in self.srcs: + t = self.srcs[label] + if isinstance(t, Temporary): + if renamer.defined(t): + self.srcs[label] = renamer.replace(t) + else: + del self.srcs[label] + + def __str__(self): + return "{} = φ({})".format(self.var, self.srcs) + + def __hash__(self): + return hash((self.var, *self.srcs.items())) + + def printIns(self, stream): + print(' # ' + str(self), file=stream) diff --git a/MiniC/Lib/RiscV.py b/MiniC/Lib/RiscV.py new file mode 100644 index 0000000..f3b53ee --- /dev/null +++ b/MiniC/Lib/RiscV.py @@ -0,0 +1,92 @@ +""" +MIF08, CAP, CodeGeneration, RiscV API +Functions to define instructions. +""" + +from Lib.Errors import MiniCInternalError +from Lib.Operands import (Condition, Immediate, Operand, Function) +from Lib.Statement import (Instru3A, AbsoluteJump, ConditionalJump, Label) + + +def call(function: Function) -> Instru3A: + """Function call.""" + return Instru3A('call', function) + + +def jump(label: Label) -> AbsoluteJump: + """Unconditional jump to label.""" + return AbsoluteJump(label) + + +def conditional_jump(label: Label, op1: Operand, cond: Condition, op2: Operand): + """Add a conditional jump to the code. + This is a wrapper around bge, bgt, beq, ... c is a Condition, like + Condition('bgt'), Condition(MiniCParser.EQ), ... + """ + return ConditionalJump(cond=cond, op1=op1, op2=op2, label=label) + + +def add(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + return Instru3A("addi", dr, sr1, sr2orimm7) + else: + return Instru3A("add", dr, sr1, sr2orimm7) + + +def mul(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + raise MiniCInternalError("Cant multiply by an immediate") + else: + return Instru3A("mul", dr, sr1, sr2orimm7) + + +def div(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + raise MiniCInternalError("Cant divide by an immediate") + else: + return Instru3A("div", dr, sr1, sr2orimm7) + + +def rem(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + raise MiniCInternalError("Cant divide by an immediate") + return Instru3A("rem", dr, sr1, sr2orimm7) + + +def sub(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + raise MiniCInternalError("Cant substract by an immediate") + return Instru3A("sub", dr, sr1, sr2orimm7) + + +def land(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + """And instruction (cannot be called `and` due to Python and).""" + return Instru3A("and", dr, sr1, sr2orimm7) + + +def lor(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + """Or instruction (cannot be called `or` due to Python or).""" + return Instru3A("or", dr, sr1, sr2orimm7) + + +def xor(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: # pragma: no cover + if isinstance(sr2orimm7, Immediate): + return Instru3A("xori", dr, sr1, sr2orimm7) + else: + return Instru3A("xor", dr, sr1, sr2orimm7) + + +def li(dr: Operand, imm7: Immediate) -> Instru3A: + return Instru3A("li", dr, imm7) + + +def mv(dr: Operand, sr: Operand) -> Instru3A: + return Instru3A("mv", dr, sr) + + +def ld(dr: Operand, mem: Operand) -> Instru3A: + return Instru3A("ld", dr, mem) + + +def sd(sr: Operand, mem: Operand) -> Instru3A: + return Instru3A("sd", sr, mem) diff --git a/MiniC/Lib/Statement.py b/MiniC/Lib/Statement.py new file mode 100644 index 0000000..cb5abae --- /dev/null +++ b/MiniC/Lib/Statement.py @@ -0,0 +1,278 @@ +""" +The base class for RISCV ASM statements is :py:class:`Statement`. +It is inherited by :py:class:`Comment`, :py:class:`Label` +and :py:class:`Instruction`. In turn, :py:class:`Instruction` +is inherited by :py:class:`Instru3A` +(for regular non-branching 3-address instructions), +:py:class:`AbsoluteJump` and :py:class:`ConditionalJump`. +""" + +from dataclasses import dataclass +from typing import (List, Dict, TypeVar) +from Lib.Operands import (Operand, Renamer, Temporary, Condition) +from Lib.Errors import MiniCInternalError + + +def regset_to_string(registerset) -> str: + """Utility function: pretty-prints a set of locations.""" + return "{" + ",".join(str(x) for x in registerset) + "}" + + +# Temporary until we can use Typing.Self in python 3.11 +TStatement = TypeVar("TStatement", bound="Statement") + + +@dataclass(unsafe_hash=True) +class Statement: + """A Statement, which is an instruction, a comment or a label.""" + + def defined(self) -> List[Operand]: + """Operands defined (written) in this instruction""" + return [] + + def used(self) -> List[Operand]: + """Operands used (read) in this instruction""" + return [] + + def substitute(self: TStatement, subst: Dict[Operand, Operand]) -> TStatement: + """Return a new instruction, cloned from this one, replacing operands + that appear as key in subst by their value.""" + raise Exception( + "substitute: Operands {} are not present in instruction {}" + .format(subst, self)) + + def with_args(self: TStatement, new_args: List[Operand]) -> TStatement: + """Return a new instruction, cloned from this one, where operands have + been replaced by new_args.""" + raise Exception( + "substitute: Operands {} are not present in instruction {}" + .format(new_args, self)) + + def printIns(self, stream): + """ + Print the statement on the given output. + Should never be called on the base class. + """ + raise NotImplementedError + + +@dataclass(unsafe_hash=True) +class Comment(Statement): + """A comment.""" + comment: str + + def __str__(self): # use only for print_dot ! + return "# {}".format(self.comment) + + def printIns(self, stream): + print(' # ' + self.comment, file=stream) + + +@dataclass(unsafe_hash=True) +class Label(Statement, Operand): + """A label is both a Statement and an Operand.""" + name: str + + def __str__(self): + return ("lbl_{}".format(self.name)) + + def __repr__(self): + return ("{}".format(self.name)) + + def printIns(self, stream): + print(str(self) + ':', file=stream) + + +@dataclass(init=False) +class Instruction(Statement): + ins: str + _read_only: bool + + def is_read_only(self): + """ + True if the instruction only reads from its operands. + + Otherwise, the first operand is considered as the destination + and others are source. + """ + return self._read_only + + def rename(self, renamer: Renamer) -> None: + raise NotImplementedError + + def args(self) -> List[Operand]: + """List of operands the instruction takes""" + raise NotImplementedError + + def defined(self): + if self.is_read_only(): + defs = [] + else: + defs = [self.args()[0]] + return defs + + def used(self) -> List[Operand]: + if self.is_read_only(): + uses = self.args() + else: + uses = self.args()[1:] + return uses + + def __str__(self): + s = self.ins + first = True + for arg in self.args(): + if first: + s += ' ' + str(arg) + first = False + else: + s += ', ' + str(arg) + return s + + def __hash__(self): + return hash((self.ins, *self.args())) + + def printIns(self, stream): + """Print the instruction on the given output.""" + print(' ', str(self), file=stream) + + +@dataclass(init=False) +class Instru3A(Instruction): + _args: List[Operand] + + def __init__(self, ins, *args: Operand): + # convention is to use lower-case in RISCV + self.ins = ins.lower() + self._args = list(args) + self._read_only = (self.ins == "call" + or self.ins == "ld" + or self.ins == "lw" + or self.ins == "lb") + if (self.ins.startswith("b") or self.ins == "j"): + raise MiniCInternalError + + def args(self): + return self._args + + def rename(self, renamer: Renamer): + old_replaced = dict() + for i, arg in enumerate(self._args): + if isinstance(arg, Temporary): + if i == 0 and not self.is_read_only(): + old_replaced[arg] = renamer.replace(arg) + new_t = renamer.fresh(arg) + elif arg in old_replaced.keys(): + new_t = old_replaced[arg] + else: + new_t = renamer.replace(arg) + self._args[i] = new_t + + def substitute(self, subst: Dict[Operand, Operand]): + for op in subst: + if op not in self.args(): + raise Exception( + "substitute: Operand {} is not present in instruction {}" + .format(op, self)) + args = [subst.get(arg, arg) + if isinstance(arg, Temporary) else arg + for arg in self.args()] + return Instru3A(self.ins, *args) + + def with_args(self, new_args: List[Operand]): + if len(new_args) != len(self._args): + raise Exception( + "substitute: Expected {} operands for {}, got {}." + .format(len(self._args), self, new_args)) + return Instru3A(self.ins, *new_args) + + def __hash__(self): + return hash(super) + + +@dataclass(init=False) +class AbsoluteJump(Instruction): + """ An Absolute Jump is a specific kind of instruction""" + ins = "j" + label: Label + _read_only = True + + def __init__(self, label: Label): + self.label = label + + def args(self) -> List[Operand]: + return [self.label] + + def rename(self, renamer: Renamer): + pass + + def substitute(self, subst: Dict[Operand, Operand]): + if subst != {}: + raise Exception( + "substitute: No possible substitution on instruction {}" + .format(self)) + return self + + def with_args(self, new_args: List[Operand]): + if new_args != self.args(): + raise Exception( + "substitute: No possible substitution on instruction {}. Old args={}, new args={}" + .format(self, self.args(), new_args)) + return self + + def __hash__(self): + return hash(super) + + def targets(self) -> List[Label]: + """Return the labels targetted by the AbsoluteJump.""" + return [self.label] + + +@dataclass(init=False) +class ConditionalJump(Instruction): + """ A Conditional Jump is a specific kind of instruction""" + cond: Condition + label: Label + op1: Operand + op2: Operand + _read_only = True + + def __init__(self, cond: Condition, op1: Operand, op2: Operand, label: Label): + self.cond = cond + self.label = label + self.op1 = op1 + self.op2 = op2 + self.ins = str(self.cond) + + def args(self): + return [self.op1, self.op2, self.label] + + def rename(self, renamer: Renamer): + if isinstance(self.op1, Temporary): + self.op1 = renamer.replace(self.op1) + if isinstance(self.op2, Temporary): + self.op2 = renamer.replace(self.op2) + + def substitute(self, subst: Dict[Operand, Operand]): + for op in subst: + if op not in self.args(): + raise Exception( + "substitute: Operand {} is not present in instruction {}" + .format(op, self)) + op1 = subst.get(self.op1, self.op1) if isinstance(self.op1, Temporary) \ + else self.op1 + op2 = subst.get(self.op2, self.op2) if isinstance(self.op2, Temporary) \ + else self.op2 + return ConditionalJump(self.cond, op1, op2, self.label) + + def with_args(self, new_args: List[Operand]): + if len(new_args) != 3: + raise Exception( + "substitute: Expected 3 operands for {}, got {}." + .format(self, new_args)) + assert isinstance(new_args[2], Label) + label: Label = new_args[2] + return ConditionalJump(self.cond, new_args[0], new_args[1], label) + + def __hash__(self): + return hash(super) diff --git a/MiniC/Lib/Terminator.py b/MiniC/Lib/Terminator.py new file mode 100644 index 0000000..98a95a4 --- /dev/null +++ b/MiniC/Lib/Terminator.py @@ -0,0 +1,153 @@ +""" +MIF08, CAP, CFG library - Terminators. + +Each :py:class:`block ` of a :py:class:`CFG ` +ends with a branching instruction called a terminator. +There are three kinds of terminators: + +- :py:class:`Lib.Statement.AbsoluteJump` is a non-conditional jump + to another block of the CFG +- :py:class:`BranchingTerminator` is a conditional branching + instruction with two successor blocks. + Unlike the class :py:class:`ConditionalJump ` + that was used in :py:class:`LinearCode `, + both successor labels have to be specified. +- :py:class:`Return` marks the end of the function + +During the construction of the CFG, :py:func:`jump2terminator` builds +a terminator for each extracted chunk of instructions. +""" + +from dataclasses import dataclass +from typing import List, Dict +from Lib.Errors import MiniCInternalError +from Lib.Operands import Operand, Renamer, Temporary, Condition +from Lib.Statement import AbsoluteJump, ConditionalJump, Instruction, Label, Statement + + +@dataclass(unsafe_hash=True) +class Return(Statement): + """A terminator that marks the end of the function.""" + + def __str__(self): + return ("return") + + def printIns(self, stream): + print("return", file=stream) + + def targets(self) -> List[Label]: + """Return the labels targetted by the Return terminator.""" + return [] + + def args(self) -> List[Operand]: + return [] + + def rename(self, renamer: Renamer): + pass + + def substitute(self, subst: Dict[Operand, Operand]): + if subst != {}: + raise Exception( + "substitute: No possible substitution on instruction {}" + .format(self)) + return self + + def with_args(self, new_args: List[Operand]): + if new_args != []: + raise Exception( + "substitute: No possible substitution on instruction {}" + .format(self)) + return self + + def is_read_only(self) -> bool: + return True + + +@dataclass(init=False) +class BranchingTerminator(Instruction): + """A terminating statement with a condition.""" + + #: The condition of the branch + cond: Condition + #: The destination label if the condition is true + label_then: Label + #: The destination label if the condition is false + label_else: Label + #: The first operand of the condition + op1: Operand + #: The second operand of the condition + op2: Operand + _read_only = True + + def __init__(self, cond: Condition, op1: Operand, op2: Operand, + label_then: Label, label_else: Label): + self.cond = cond + self.label_then = label_then + self.label_else = label_else + self.op1 = op1 + self.op2 = op2 + self.ins = str(self.cond) + + def args(self) -> List[Operand]: + return [self.op1, self.op2, self.label_then, self.label_else] + + def targets(self) -> List[Label]: + """Return the labels targetted by the Branching terminator.""" + return [self.label_then, self.label_else] + + def rename(self, renamer: Renamer): + if isinstance(self.op1, Temporary): + self.op1 = renamer.replace(self.op1) + if isinstance(self.op2, Temporary): + self.op2 = renamer.replace(self.op2) + + def substitute(self, subst: Dict[Operand, Operand]): + for op in subst: + if op not in self.args(): + raise Exception( + "substitute: Operand {} is not present in instruction {}" + .format(op, self)) + op1 = subst.get(self.op1, self.op1) if isinstance(self.op1, Temporary) \ + else self.op1 + op2 = subst.get(self.op2, self.op2) if isinstance(self.op2, Temporary) \ + else self.op2 + return BranchingTerminator(self.cond, op1, op2, self.label_then, self.label_else) + + def with_args(self, new_args: List[Operand]): + if len(new_args) != 4: + raise Exception( + "substitute: Invalid number of arguments for instruction {}, expected 4 got {}" + .format(self, new_args)) + op1 = new_args[0] + op2 = new_args[1] + return BranchingTerminator(self.cond, op1, op2, self.label_then, self.label_else) + + def __hash__(self): + return hash(super) + + +Terminator = Return | AbsoluteJump | BranchingTerminator +"""Type alias for terminators""" + + +def jump2terminator(j: ConditionalJump | AbsoluteJump | None, + next_label: Label | None) -> Terminator: + """ + Construct the Terminator associated to the potential jump j + to the potential label next_label. + """ + match j: + case ConditionalJump(): + if (next_label is None): + raise MiniCInternalError( + "jump2terminator: Missing secondary label for instruction {}" + .format(j)) + label_else = next_label + return BranchingTerminator(j.cond, j.op1, j.op2, j.label, label_else) + case AbsoluteJump(): + return AbsoluteJump(label=j.label) + case _: + if next_label: + return AbsoluteJump(next_label) + else: + return Return() diff --git a/MiniC/Lib/__init__.py b/MiniC/Lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/MiniC/Makefile b/MiniC/Makefile index bb90ed4..e37becc 100644 --- a/MiniC/Makefile +++ b/MiniC/Makefile @@ -35,8 +35,8 @@ doc: antlr sphinx-apidoc -e -f -o doc/api . TP* replace_* *Wrapper* MiniC* conf* test* make -C doc html -test: test-interpret +test: test-interpret test-codegen test-pyright: antlr @@ -67,8 +67,6 @@ test-naive: test-pyright antlr test-mem: test-pyright antlr $(LINEAR) python3 -m pytest $(PYTEST_BASE_OPTS) $(PYTEST_OPTS) ./test_codegen.py -k 'test_alloc_mem' -test-hybrid: test-pyright antlr - $(LINEAR) python3 -m pytest $(PYTEST_BASE_OPTS) $(PYTEST_OPTS) ./test_codegen.py -k 'test_alloc_hybrid' # Test for all but the smart allocator, i.e. everything that lab4 should pass: test-lab4: test-pyright antlr diff --git a/MiniC/README-SSA.md b/MiniC/README-SSA.md new file mode 100644 index 0000000..82bd87a --- /dev/null +++ b/MiniC/README-SSA.md @@ -0,0 +1,21 @@ +# MiniC Compiler +LAB5a (Control Flow Graph in SSA Form) & LAB5b (Smart Register Allocation), CAP 2022-23 + +# Authors + +YOUR NAME HERE + +# Contents + +TODO: +- Explain any design choices you may have made. +- Do not forget to remove all debug traces from your code! +- Did you implement an extension? + +# Test design + +TODO: give the main objectives of your tests. + +# Known bugs + +TODO: bugs you could not fix (if any). diff --git a/MiniC/README-alloc.md b/MiniC/README-alloc.md new file mode 100644 index 0000000..b25af3e --- /dev/null +++ b/MiniC/README-alloc.md @@ -0,0 +1,38 @@ +# MiniC Compiler +LAB5 (smart code generation), MIF08 / CAP 2022-23 + +# Authors + +YOUR NAME HERE + +# Contents + +TODO for STUDENTS : Say a bit about the code infrastructure ... + +# Howto + +To compile and run a program: +``` +$ python3 ./MiniCC.py --reg-alloc=smart TP04/tests/provided/step1/test00.c +Code will be generated in file TP04/tests/provided/step1/test00.s +$ riscv64-unknown-elf-gcc TP04/tests/provided/step1/test00.s ../TP01/riscv/libprint.s -o /tmp/a.out +$ spike pk /tmp/a.out +``` + +To launch the testsuite: +``` +make test-smart +``` + +# Test design + +TODO: explain your tests + +# Design choices + +TODO: explain your choices + +# Known bugs + +TODO: Bugs and limitations. + diff --git a/MiniC/README-codegen.md b/MiniC/README-codegen.md new file mode 100644 index 0000000..e6923a0 --- /dev/null +++ b/MiniC/README-codegen.md @@ -0,0 +1,57 @@ +# MiniC Compiler +LAB4 (simple code generation), MIF08 / CAP 2022-23 + +# Authors + +YOUR NAME HERE + +# Contents + +TODO for STUDENTS : Say a bit about the code infrastructure ... + +# Test design + +TODO: explain your tests + +# Design choices + +TODO: explain your choices. How did you implement boolean not? Did you implement an extension? + +# Known bugs + +TODO: Bugs and limitations. + +# Checklists + +A check ([X]) means that the feature is implemented +and *tested* with appropriate test cases. + +## Code generation + +- [ ] Number Atom +- [ ] Boolean Atom +- [ ] Id Atom +- [ ] Additive expression +- [ ] Multiplicative expression +- [ ] UnaryMinus expression +- [ ] Or expression +- [ ] And expression +- [ ] Equality expression +- [ ] Relational expression (! many cases -> many tests) +- [ ] Not expression + +## Statements + +- [ ] Prog, assignements +- [ ] While +- [ ] Cond Block +- [ ] If +- [ ] Nested ifs +- [ ] Nested whiles + +## Allocation + +- [ ] Naive allocation +- [ ] All in memory allocation +- [ ] Massive tests of memory allocation + diff --git a/MiniC/README-functions.md b/MiniC/README-functions.md new file mode 100644 index 0000000..36ca0f6 --- /dev/null +++ b/MiniC/README-functions.md @@ -0,0 +1,60 @@ +# MiniC Compiler +LAB6 (code generation for functions), MIF08 / CAP 2022-23 + +# Authors + +YOUR NAME HERE + +# Contents + +TODO: Say a bit about the code infrastructure ... + +# Howto + +As in the previous labs. + +`make test-codegen SSA=1` to lauch pyright and the testsuite +with the three allocators (do not forget the options you can add). + +# Test design + +TODO: give the main objectives of your tests. + +# Design choices + +TODO: explain your choices + +# Known bugs + +TODO: bugs and limitations you could not fix (if any). + +# Checklists + +A check ([X]) means that the feature is implemented +and *tested* with appropriate test cases. + +## Parser + +- [ ] Function definition +- [ ] Function declaration +- [ ] Function call + +## Typer + +- [ ] Function declaration +- [ ] Function definition +- [ ] Function call +- [ ] Function return + +## Code generation + +- [ ] Function return +- [ ] Callee-saved registers +- [ ] Function call +- [ ] Getting the result of a function call +- [ ] Caller-saved registers +- [ ] Increase the size of the stack for callee/caller-saved registers +- [ ] Temporaries for giving arguments to a function call +- [ ] Temporaries for retriving arguments at the beginning of a function + + diff --git a/MiniC/TP04/AllInMemAllocator.py b/MiniC/TP04/AllInMemAllocator.py new file mode 100644 index 0000000..6c24403 --- /dev/null +++ b/MiniC/TP04/AllInMemAllocator.py @@ -0,0 +1,33 @@ +from Lib import RiscV +from Lib.Operands import Temporary, Operand, S +from Lib.Statement import Instruction +from Lib.Allocator import Allocator +from typing import List + + +class AllInMemAllocator(Allocator): + + def replace(self, old_instr: Instruction) -> List[Instruction]: + """Replace Temporary operands with the corresponding allocated + memory location.""" + numreg = 1 + before: List[Instruction] = [] + after: List[Instruction] = [] + new_args: List[Operand] = [] + # TODO: compute before,after,args. + # TODO: iterate over old_args, check which argument + # TODO: is a temporary (e.g. isinstance(..., Temporary)), + # TODO: and if so, generate ld/sd accordingly. Replace the + # TODO: temporary with S[1], S[2] or S[3] physical registers. + new_instr = old_instr.with_args(new_args) + return before + [new_instr] + after + + def prepare(self) -> None: + """Allocate all temporaries to memory. + Invariants: + - Expanded instructions can use s2 and s3 + (to store the values of temporaries before the actual instruction). + """ + self._fdata._pool.set_temp_allocation( + {temp: self._fdata.fresh_offset() + for temp in self._fdata._pool.get_all_temps()}) diff --git a/MiniC/TP04/BuildCFG.py b/MiniC/TP04/BuildCFG.py new file mode 100644 index 0000000..851e094 --- /dev/null +++ b/MiniC/TP04/BuildCFG.py @@ -0,0 +1,111 @@ +""" +CAP, CodeGeneration, CFG construction from linear code +""" + +from typing import List +from Lib.Errors import MiniCInternalError +from Lib.FunctionData import FunctionData +from Lib.LinearCode import LinearCode, CodeStatement +from Lib.Statement import ( + Instru3A, Comment, Label, AbsoluteJump, ConditionalJump +) +from Lib.Terminator import jump2terminator +from Lib.CFG import Block, BlockInstr, CFG + + +def find_leaders(instructions: List[CodeStatement]) -> List[int]: + """ + Find the leaders in the given list of instructions as linear code. + Returns a list of indices in the instruction list whose first is 0 and + last is len(instructions) + """ + leaders: List[int] = [0] + # TODO fill leaders + # The final "ret" is also a form of jump + leaders.append(len(instructions)) + return leaders + + +def separate_with_leaders(instructions: List[CodeStatement], + leaders: List[int]) -> List[List[CodeStatement]]: + """ + Partition the lists instructions into a list containing for + elements the lists of statements between indices + leaders[i] (included) and leaders[i+1] (excluded). + + If leaders[i] = leaders[i+1], do not add the empty list. + """ + chunks: List[List[CodeStatement]] = [] + for i in range(0, len(leaders)-1): + start = leaders[i] + end = leaders[i+1] + if start != end: + # Avoid corner-cases when a label immediately follows a jump + chunks.append(instructions[start:end]) + return chunks + + +def prepare_chunk(pre_chunk: List[CodeStatement], fdata: FunctionData) -> tuple[ + Label, ConditionalJump | AbsoluteJump | None, List[BlockInstr]]: + """ + Extract the potential label (respectively jump) + at the start (respectively end) of the list instrs_chunk, + and return the tuple with this label, this jump and the + rest of instrs_chunk. + + If there is no label at the start then return a fresh label instead, + thanks to fdata (use `fdata.fresh_label(fdata._name)` for instance). + If there is no jump at the end, return None instead. + + Raise an error if there is a label not in first position in pre_chunk, + or a jump not in last position. + """ + label = None + jump = None + inner_statements: List[CodeStatement] = pre_chunk + # Extract the first instruction from inner_statements if it is a label, or create a fresh one + raise NotImplementedError() # TODO + # Extract the last instruction from inner_statements if it is a jump, or do nothing + raise NotImplementedError() # TODO + # Check that there is no other label or jump left in inner_statements + l: List[BlockInstr] = [] + for i in inner_statements: + match i: + case AbsoluteJump() | ConditionalJump(): + raise MiniCInternalError( + "prepare_chunk: Jump {} not in last position of a chunk" + .format(i)) + case Label(): + raise MiniCInternalError( + "prepare_chunk: Label {} not in first position of a chunk" + .format(i)) + case Instru3A() | Comment(): + l.append(i) + return (label, jump, l) + + +def build_cfg(linCode: LinearCode) -> CFG: + """Extract the blocks from the linear code and add them to the CFG.""" + fdata = linCode.fdata + cfg = CFG(fdata) + instructions = linCode.get_instructions() + # 1. Identify Leaders + leaders = find_leaders(instructions) + # 2. Extract Chunks of Instructions + pre_chunks: List[List[CodeStatement]] = separate_with_leaders(instructions, leaders) + chunks: List[tuple[Label, ConditionalJump | AbsoluteJump | None, List[BlockInstr]]] = [ + prepare_chunk(pre_chunk, fdata) for pre_chunk in pre_chunks] + # 3. Build the Blocks + next_label = None + for (label, jump, block_instrs) in reversed(chunks): + term = jump2terminator(jump, next_label) + block = Block(label, block_instrs, term) + cfg.add_block(block) + next_label = label + # 4. Fill the edges + for block in cfg.get_blocks(): + for dest in cfg.out_blocks(block): + cfg.add_edge(block, dest) + # 5. Identify the entry label of the CFG + cfg.set_start(chunks[0][0]) + return cfg diff --git a/MiniC/TP04/LinearizeCFG.py b/MiniC/TP04/LinearizeCFG.py new file mode 100644 index 0000000..a3b6a37 --- /dev/null +++ b/MiniC/TP04/LinearizeCFG.py @@ -0,0 +1,40 @@ +""" +CAP, CodeGeneration, CFG linearization to a list of statements +""" + +from typing import List, Set +from Lib.Statement import Statement, AbsoluteJump, ConditionalJump +from Lib.Terminator import Return, BranchingTerminator +from Lib.CFG import Block, CFG + + +def ordered_blocks_list(cfg: CFG) -> List[Block]: + """ + Compute a list of blocks with optimized ordering for linearization. + """ + # TODO + return cfg.get_blocks() + + +def linearize(cfg: CFG) -> List[Statement]: + """ + Linearize the given control flow graph as a list of instructions. + """ + # TODO + l: List[Statement] = [] # Linearized CFG + blocks: List[Block] = ordered_blocks_list(cfg) # All blocks of the CFG + for i, block in enumerate(blocks): + # 1. Add the label of the block to the linearization + l.append(block.get_label()) + # 2. Add the body of the block to the linearization + l.extend(block.get_body()) + # 3. Add the terminator of the block to the linearization + match block.get_terminator(): + case BranchingTerminator() as j: + l.append(ConditionalJump(j.cond, j.op1, j.op2, j.label_then)) + l.append(AbsoluteJump(j.label_else)) + case AbsoluteJump() as j: + l.append(AbsoluteJump(j.label)) + case Return(): + l.append(AbsoluteJump(cfg.get_end())) + return l diff --git a/MiniC/TP04/MiniCCodeGen3AVisitor.py b/MiniC/TP04/MiniCCodeGen3AVisitor.py new file mode 100644 index 0000000..6098a19 --- /dev/null +++ b/MiniC/TP04/MiniCCodeGen3AVisitor.py @@ -0,0 +1,196 @@ +from typing import List +from MiniCVisitor import MiniCVisitor +from MiniCParser import MiniCParser +from Lib.LinearCode import LinearCode +from Lib import RiscV +from Lib.RiscV import Condition +from Lib import Operands +from antlr4.tree.Trees import Trees +from Lib.Errors import MiniCInternalError, MiniCUnsupportedError + +""" +CAP, MIF08, three-address code generation + simple alloc +This visitor constructs an object of type "LinearCode". +""" + + +class MiniCCodeGen3AVisitor(MiniCVisitor): + + _current_function: LinearCode + + def __init__(self, debug, parser): + super().__init__() + self._parser = parser + self._debug = debug + self._functions = [] + self._lastlabel = "" + + def get_functions(self) -> List[LinearCode]: + return self._functions + + def printSymbolTable(self): # pragma: no cover + print("--variables to temporaries map--") + for keys, values in self._symbol_table.items(): + print(keys + '-->' + str(values)) + + # handle variable decl + + def visitVarDecl(self, ctx) -> None: + type_str = ctx.typee().getText() + vars_l = self.visit(ctx.id_l()) + for name in vars_l: + if name in self._symbol_table: + raise MiniCInternalError( + "Variable {} has already been declared".format(name)) + else: + tmp = self._current_function.fdata.fresh_tmp() + self._symbol_table[name] = tmp + if type_str not in ("int", "bool"): + raise MiniCUnsupportedError("Unsupported type " + type_str) + # Initialization to 0 or False, both represented with 0 + self._current_function.add_instruction( + RiscV.li(tmp, Operands.Immediate(0))) + + def visitIdList(self, ctx) -> List[str]: + t = self.visit(ctx.id_l()) + t.append(ctx.ID().getText()) + return t + + def visitIdListBase(self, ctx) -> List[str]: + return [ctx.ID().getText()] + + # expressions + + def visitParExpr(self, ctx) -> Operands.Temporary: + return self.visit(ctx.expr()) + + def visitIntAtom(self, ctx) -> Operands.Temporary: + val = Operands.Immediate(int(ctx.getText())) + dest_temp = self._current_function.fdata.fresh_tmp() + self._current_function.add_instruction(RiscV.li(dest_temp, val)) + return dest_temp + + def visitFloatAtom(self, ctx) -> Operands.Temporary: + raise MiniCUnsupportedError("float literal") + + def visitBooleanAtom(self, ctx) -> Operands.Temporary: + # true is 1 false is 0 + raise NotImplementedError() # TODO + + def visitIdAtom(self, ctx) -> Operands.Temporary: + try: + # get the temporary associated to id + return self._symbol_table[ctx.getText()] + except KeyError: # pragma: no cover + raise MiniCInternalError( + "Undefined variable {}, this should have failed to typecheck." + .format(ctx.getText()) + ) + + def visitStringAtom(self, ctx) -> Operands.Temporary: + raise MiniCUnsupportedError("string atom") + + # now visit expressions + + def visitAtomExpr(self, ctx) -> Operands.Temporary: + return self.visit(ctx.atom()) + + def visitAdditiveExpr(self, ctx) -> Operands.Temporary: + assert ctx.myop is not None + tmpl: Operands.Temporary = self.visit(ctx.expr(0)) + tmpr: Operands.Temporary = self.visit(ctx.expr(1)) + raise NotImplementedError() # TODO + + def visitOrExpr(self, ctx) -> Operands.Temporary: + raise NotImplementedError() # TODO + + def visitAndExpr(self, ctx) -> Operands.Temporary: + raise NotImplementedError() # TODO + + def visitEqualityExpr(self, ctx) -> Operands.Temporary: + return self.visitRelationalExpr(ctx) + + def visitRelationalExpr(self, ctx) -> Operands.Temporary: + assert ctx.myop is not None + c = Condition(ctx.myop.type) + if self._debug: + print("relational expression:") + print(Trees.toStringTree(ctx, [], self._parser)) + print("Condition:", c) + raise NotImplementedError() # TODO + + def visitMultiplicativeExpr(self, ctx) -> Operands.Temporary: + assert ctx.myop is not None + div_by_zero_lbl = self._current_function.fdata.get_label_div_by_zero() + raise NotImplementedError() # TODO + + def visitNotExpr(self, ctx) -> Operands.Temporary: + raise NotImplementedError() # TODO + + def visitUnaryMinusExpr(self, ctx) -> Operands.Temporary: + raise NotImplementedError("unaryminusexpr") # TODO + + def visitProgRule(self, ctx) -> None: + self.visitChildren(ctx) + + def visitFuncDef(self, ctx) -> None: + funcname = ctx.ID().getText() + self._current_function = LinearCode(funcname) + self._symbol_table = dict() + + self.visit(ctx.vardecl_l()) + self.visit(ctx.block()) + self._current_function.add_comment("Return at end of function:") + # This skeleton doesn't deal properly with functions, and + # hardcodes a "return 0;" at the end of function. Generate + # code for this "return 0;". + self._current_function.add_instruction( + RiscV.li(Operands.A0, Operands.Immediate(0))) + self._functions.append(self._current_function) + del self._current_function + + def visitAssignStat(self, ctx) -> None: + if self._debug: + print("assign statement, rightexpression is:") + print(Trees.toStringTree(ctx.expr(), [], self._parser)) + expr_temp = self.visit(ctx.expr()) + name = ctx.ID().getText() + self._current_function.add_instruction(RiscV.mv(self._symbol_table[name], expr_temp)) + + def visitIfStat(self, ctx) -> None: + if self._debug: + print("if statement") + end_if_label = self._current_function.fdata.fresh_label("end_if") + raise NotImplementedError() # TODO + self._current_function.add_label(end_if_label) + + def visitWhileStat(self, ctx) -> None: + if self._debug: + print("while statement, condition is:") + print(Trees.toStringTree(ctx.expr(), [], self._parser)) + print("and block is:") + print(Trees.toStringTree(ctx.stat_block(), [], self._parser)) + raise NotImplementedError() # TODO + # visit statements + + def visitPrintlnintStat(self, ctx) -> None: + expr_loc = self.visit(ctx.expr()) + if self._debug: + print("print_int statement, expression is:") + print(Trees.toStringTree(ctx.expr(), [], self._parser)) + self._current_function.add_instruction_PRINTLN_INT(expr_loc) + + def visitPrintlnboolStat(self, ctx) -> None: + expr_loc = self.visit(ctx.expr()) + self._current_function.add_instruction_PRINTLN_INT(expr_loc) + + def visitPrintlnfloatStat(self, ctx) -> None: + raise MiniCUnsupportedError("Unsupported type float") + + def visitPrintlnstringStat(self, ctx) -> None: + raise MiniCUnsupportedError("Unsupported type string") + + def visitStatList(self, ctx) -> None: + for stat in ctx.stat(): + self._current_function.add_comment(Trees.toStringTree(stat, [], self._parser)) + self.visit(stat) diff --git a/MiniC/TP04/tests/provided/dataflow/df00.c b/MiniC/TP04/tests/provided/dataflow/df00.c new file mode 100644 index 0000000..1ce157a --- /dev/null +++ b/MiniC/TP04/tests/provided/dataflow/df00.c @@ -0,0 +1,13 @@ +#include "printlib.h" + +int main() { + + int n,u; + n=6; + println_int(n); + + return 0; +} + +// EXPECTED +// 6 \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/dataflow/df01.c b/MiniC/TP04/tests/provided/dataflow/df01.c new file mode 100644 index 0000000..acbf660 --- /dev/null +++ b/MiniC/TP04/tests/provided/dataflow/df01.c @@ -0,0 +1,15 @@ +#include "printlib.h" + +int main() { + + int n,u,v; + n=6; + u=12; + v=n+u; + println_int(v); + + return 0; +} + +// EXPECTED +// 18 \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/dataflow/df02.c b/MiniC/TP04/tests/provided/dataflow/df02.c new file mode 100644 index 0000000..55282c9 --- /dev/null +++ b/MiniC/TP04/tests/provided/dataflow/df02.c @@ -0,0 +1,14 @@ +#include "printlib.h" + +int main() { + + int n,v; + bool u; + n=6; + u=12>n; + println_bool(1 1) + { + n = n - 1; + u = u + n; + } + println_int(u); + return 0; +} + +// EXPECTED +// 15 \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/dataflow/df04.c b/MiniC/TP04/tests/provided/dataflow/df04.c new file mode 100644 index 0000000..638a3a8 --- /dev/null +++ b/MiniC/TP04/tests/provided/dataflow/df04.c @@ -0,0 +1,16 @@ +#include "printlib.h" + +int main() +{ + + int x, y; + x = 2; + if (x < 4) + x = 4; + else + x = 5; + + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/dataflow/df05.c b/MiniC/TP04/tests/provided/dataflow/df05.c new file mode 100644 index 0000000..ccee7fb --- /dev/null +++ b/MiniC/TP04/tests/provided/dataflow/df05.c @@ -0,0 +1,14 @@ +#include "printlib.h" + +int main() +{ + int x; + x = 0; + while (x < 4) + { + x = x + 1; + } + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step1/test00.c b/MiniC/TP04/tests/provided/step1/test00.c new file mode 100644 index 0000000..67b3b17 --- /dev/null +++ b/MiniC/TP04/tests/provided/step1/test00.c @@ -0,0 +1,9 @@ +#include "printlib.h" + +int main() { + println_int(42); + return 0; +} + +// EXPECTED +// 42 \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step1/test00b.c b/MiniC/TP04/tests/provided/step1/test00b.c new file mode 100644 index 0000000..0b61612 --- /dev/null +++ b/MiniC/TP04/tests/provided/step1/test00b.c @@ -0,0 +1,11 @@ +#include "printlib.h" + +int main() { + + int x,y; + x=4; + y=12+x; + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step1/test00d.c b/MiniC/TP04/tests/provided/step1/test00d.c new file mode 100644 index 0000000..003f1a9 --- /dev/null +++ b/MiniC/TP04/tests/provided/step1/test00d.c @@ -0,0 +1,11 @@ +#include "printlib.h" + +int main() { + + int a,n; + n=1; + a=n+12; + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step1/test01.c b/MiniC/TP04/tests/provided/step1/test01.c new file mode 100644 index 0000000..0ee820c --- /dev/null +++ b/MiniC/TP04/tests/provided/step1/test01.c @@ -0,0 +1,11 @@ +#include "printlib.h" + +int main() { + + int n; + n=6; + + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step1/test_print.c b/MiniC/TP04/tests/provided/step1/test_print.c new file mode 100644 index 0000000..9e17837 --- /dev/null +++ b/MiniC/TP04/tests/provided/step1/test_print.c @@ -0,0 +1,11 @@ +#include "printlib.h" + +int main() { + + println_int(43); + return 0; +} + +// EXPECTED +// 43 + diff --git a/MiniC/TP04/tests/provided/step1/test_var.c b/MiniC/TP04/tests/provided/step1/test_var.c new file mode 100644 index 0000000..80ba470 --- /dev/null +++ b/MiniC/TP04/tests/provided/step1/test_var.c @@ -0,0 +1,12 @@ +#include "printlib.h" + +int main() { + + int x; + x = 42; + println_int(x); + return 0; +} + +// EXPECTED +// 42 diff --git a/MiniC/TP04/tests/provided/step1/test_var_plus.c b/MiniC/TP04/tests/provided/step1/test_var_plus.c new file mode 100644 index 0000000..4d2f57b --- /dev/null +++ b/MiniC/TP04/tests/provided/step1/test_var_plus.c @@ -0,0 +1,16 @@ +#include "printlib.h" + +int main() { + + int x; + x = 42; + println_int(x + x); + println_int(x + 1); + println_int(1 + x); + return 0; +} + +// EXPECTED +// 84 +// 43 +// 43 diff --git a/MiniC/TP04/tests/provided/step1/test_vars.c b/MiniC/TP04/tests/provided/step1/test_vars.c new file mode 100644 index 0000000..99501db --- /dev/null +++ b/MiniC/TP04/tests/provided/step1/test_vars.c @@ -0,0 +1,20 @@ +#include "printlib.h" + +int main() { + + int x, y; + x = 42; + y = 66; + println_int(x + y); + x = 1; + println_int(x + y); + y = 2; + println_int(x + y); + return 0; +} + +// EXPECTED +// 108 +// 67 +// 3 + diff --git a/MiniC/TP04/tests/provided/step2/test02.c b/MiniC/TP04/tests/provided/step2/test02.c new file mode 100644 index 0000000..6072740 --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test02.c @@ -0,0 +1,16 @@ +#include "printlib.h" + +int main() { + + int x,y; + + x = 9; + if (x < 2) + y=7; + else + y=12; + x = y; + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step2/test04.c b/MiniC/TP04/tests/provided/step2/test04.c new file mode 100644 index 0000000..f15d8fb --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test04.c @@ -0,0 +1,13 @@ +#include "printlib.h" + +int main() { + + int n; + bool a,b; + n=1; + a=true; + b=(a==(n<6)); + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step2/test05.c b/MiniC/TP04/tests/provided/step2/test05.c new file mode 100644 index 0000000..98c4a3d --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test05.c @@ -0,0 +1,13 @@ +#include "printlib.h" + +int main() { + + int x,y; + x=3; + if (x<5) { + y=x+1; + } + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step2/test06.c b/MiniC/TP04/tests/provided/step2/test06.c new file mode 100644 index 0000000..b8d8381 --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test06.c @@ -0,0 +1,16 @@ +#include "printlib.h" + +int main() { + + int x,y,z; + x=(2); + if (((x)<(3))) { + y=7; + } else { + y=8; + } + z=y+1; + return 0; +} + +// EXPECTED diff --git a/MiniC/TP04/tests/provided/step2/test07.c b/MiniC/TP04/tests/provided/step2/test07.c new file mode 100644 index 0000000..7a934ce --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test07.c @@ -0,0 +1,20 @@ +#include "printlib.h" + +int main() { + + int x,y,z,u; + x=3; + if (x < 4) { + z=4; + } + else if ( x < 5) { + z=5; + } + else { + z=6 ; + } + u=z+1; + return 0; +} + +// EXPECTED \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/step2/test_bool.c b/MiniC/TP04/tests/provided/step2/test_bool.c new file mode 100644 index 0000000..e7a70ce --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test_bool.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +int main() { + + bool b; + b = false; + println_bool(b); + b = true; + println_bool(b); + println_bool(true); + println_bool(false); + return 0; +} + +// EXPECTED +// 0 +// 1 +// 1 +// 0 diff --git a/MiniC/TP04/tests/provided/step2/test_compare_1_1.c b/MiniC/TP04/tests/provided/step2/test_compare_1_1.c new file mode 100644 index 0000000..74c0883 --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test_compare_1_1.c @@ -0,0 +1,10 @@ +#include "printlib.h" + +int main() { + + println_bool(3 >= 2); + return 0; +} + +// EXPECTED +// 1 diff --git a/MiniC/TP04/tests/provided/step2/test_if2.c b/MiniC/TP04/tests/provided/step2/test_if2.c new file mode 100644 index 0000000..deeb428 --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test_if2.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +int main() { + + if (10 == 10) { + println_int(12); + } else if (10 == 10) { + println_int(15); + } else { + println_int(13); + } + println_int(14); + return 0; +} + +// EXPECTED +// 12 +// 14 + diff --git a/MiniC/TP04/tests/provided/step2/test_while1.c b/MiniC/TP04/tests/provided/step2/test_while1.c new file mode 100644 index 0000000..3ab8423 --- /dev/null +++ b/MiniC/TP04/tests/provided/step2/test_while1.c @@ -0,0 +1,25 @@ +#include "printlib.h" + +int main() { + + int n; + + n = 9; + while (n > 0) { + n = n-1 ; + println_int(n) ; + } + + return 0; +} + +// EXPECTED +// 8 +// 7 +// 6 +// 5 +// 4 +// 3 +// 2 +// 1 +// 0 diff --git a/MiniC/TP04/tests/provided/test_while2b.c b/MiniC/TP04/tests/provided/test_while2b.c new file mode 100644 index 0000000..9569b42 --- /dev/null +++ b/MiniC/TP04/tests/provided/test_while2b.c @@ -0,0 +1,18 @@ +#include "printlib.h" + +int main() { + + int a,n; + + n = 1; + a = 7; + while (n < a) { + n = n+1; + } + println_int(n); + + return 0; +} + +// EXPECTED +// 7 diff --git a/MiniC/TP04/tests/provided/unsupported/float.c b/MiniC/TP04/tests/provided/unsupported/float.c new file mode 100644 index 0000000..c7c06fa --- /dev/null +++ b/MiniC/TP04/tests/provided/unsupported/float.c @@ -0,0 +1,9 @@ +int main() { + float f; + return 0; +} + +// SKIP TEST EXPECTED +// EXITCODE 5 +// EXPECTED +// Unsupported type float \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/unsupported/print_float.c b/MiniC/TP04/tests/provided/unsupported/print_float.c new file mode 100644 index 0000000..93ab94e --- /dev/null +++ b/MiniC/TP04/tests/provided/unsupported/print_float.c @@ -0,0 +1,9 @@ +int main() { + println_float(0.0); + return 0; +} + +// SKIP TEST EXPECTED +// EXITCODE 5 +// EXPECTED +// Unsupported type float diff --git a/MiniC/TP04/tests/provided/unsupported/print_string.c b/MiniC/TP04/tests/provided/unsupported/print_string.c new file mode 100644 index 0000000..a3c37b5 --- /dev/null +++ b/MiniC/TP04/tests/provided/unsupported/print_string.c @@ -0,0 +1,9 @@ +int main() { + println_string("Hello"); + return 0; +} + +// SKIP TEST EXPECTED +// EXITCODE 5 +// EXPECTED +// Unsupported type string \ No newline at end of file diff --git a/MiniC/TP04/tests/provided/unsupported/string.c b/MiniC/TP04/tests/provided/unsupported/string.c new file mode 100644 index 0000000..f66b214 --- /dev/null +++ b/MiniC/TP04/tests/provided/unsupported/string.c @@ -0,0 +1,9 @@ +int main() { + string b; + return 0; +} + +// SKIP TEST EXPECTED +// EXITCODE 5 +// EXPECTED +// Unsupported type string \ No newline at end of file diff --git a/MiniC/TP05/EnterSSA.py b/MiniC/TP05/EnterSSA.py new file mode 100644 index 0000000..757c702 --- /dev/null +++ b/MiniC/TP05/EnterSSA.py @@ -0,0 +1,70 @@ +""" +CAP, SSA Intro, Elimination and Optimisations +Functions to convert a CFG into SSA Form. +""" + +from typing import List, Dict, Set +from Lib.CFG import Block, CFG +from Lib.Operands import Renamer +from Lib.Statement import Instruction +from Lib.PhiNode import PhiNode +from Lib.Dominators import computeDom, computeDT, computeDF + + +def insertPhis(cfg: CFG, DF: Dict[Block, Set[Block]]) -> None: + """ + `insertPhis(CFG, DF)` inserts phi nodes in `cfg` where needed. + At this point, phi nodes will look like `temp_x = φ(temp_x, ..., temp_x)`. + + This is an helper function called during SSA entry. + """ + for var, defs in cfg.gather_defs().items(): + has_phi: Set[Block] = set() + queue: List[Block] = list(defs) + while queue: + d = queue.pop(0) + for b in DF[d]: + if b not in has_phi: + # TODO add a phi node in block `b` (Lab 5a, Exercise 4) + raise NotImplementedError("insertPhis") + + +def rename_block(cfg: CFG, DT: Dict[Block, Set[Block]], renamer: Renamer, b: Block) -> None: + """ + Rename variables from block b. + + This is an auxiliary function for `rename_variables`. + """ + renamer = renamer.copy() + for i in b.get_all_statements(): + if isinstance(i, Instruction | PhiNode): + i.rename(renamer) + for succ in cfg.out_blocks(b): + for i in succ.get_phis(): + assert (isinstance(i, PhiNode)) + i.rename_from(renamer, b.get_label()) + # TODO recursive call(s) of rename_block (Lab 5a, Exercise 5) + + +def rename_variables(cfg: CFG, DT: Dict[Block, Set[Block]]) -> None: + """ + Rename variables in the CFG, to transform `temp_x = φ(temp_x, ..., temp_x)` + into `temp_x = φ(temp_0, ... temp_n)`. + + This is an helper function called during SSA entry. + """ + renamer = Renamer(cfg.fdata._pool) + # TODO initial call(s) to rename_block (Lab 5a, Exercise 5) + + +def enter_ssa(cfg: CFG, dom_graphs=False, basename="prog") -> None: + """ + Convert the CFG `cfg` into SSA Form: + compute the dominance frontier, then insert phi nodes and finally + rename variables accordingly. + + `dom_graphs` indicates if we have to print the domination graphs. + `basename` is used for the names of the produced graphs. + """ + # TODO implement this function (Lab 5a, Exercise 2) + raise NotImplementedError("enter_ssa") diff --git a/MiniC/TP05/ExitSSA.py b/MiniC/TP05/ExitSSA.py new file mode 100644 index 0000000..d705e86 --- /dev/null +++ b/MiniC/TP05/ExitSSA.py @@ -0,0 +1,44 @@ +""" +CAP, SSA Intro, Elimination and Optimisations +Functions to convert a CFG out of SSA Form. +""" + +from typing import cast, List +from Lib import RiscV +from Lib.CFG import Block, BlockInstr, CFG +from Lib.Operands import Temporary +from Lib.Statement import AbsoluteJump +from Lib.Terminator import BranchingTerminator, Return +from Lib.PhiNode import PhiNode +from TP05.SequentializeMoves import sequentialize_moves + + +def generate_moves_from_phis(phis: List[PhiNode], parent: Block) -> List[BlockInstr]: + """ + `generate_moves_from_phis(phis, parent)` builds a list of move instructions + to be inserted in a new block between `parent` and the block with phi nodes + `phis`. + + This is an helper function called during SSA exit. + """ + moves: List[BlockInstr] = [] + # TODO compute 'moves', a list of 'mv' instructions to insert under parent + # (Lab 5a, Exercise 6) + return moves + + +def exit_ssa(cfg: CFG, is_smart: bool) -> None: + """ + `exit_ssa(cfg)` replaces phi nodes with move instructions to exit SSA form. + + `is_smart` is set to true when smart register allocation is enabled (Lab 5b). + """ + for b in cfg.get_blocks(): + phis = cast(List[PhiNode], b.get_phis()) # Use cast for Pyright + b.remove_all_phis() # Remove all phi nodes in the block + parents: List[Block] = b.get_in().copy() # Copy as we modify it by adding blocks + for parent in parents: + moves = generate_moves_from_phis(phis, parent) + # TODO Add the block containing 'moves' to 'cfg' + # and update edges and jumps accordingly (Lab 5a, Exercise 6) + raise NotImplementedError("exit_ssa") diff --git a/MiniC/TP05/LivenessDataFlow.py b/MiniC/TP05/LivenessDataFlow.py new file mode 100644 index 0000000..93c2d90 --- /dev/null +++ b/MiniC/TP05/LivenessDataFlow.py @@ -0,0 +1,99 @@ +from typing import Dict, Set +from Lib.Operands import Operand, Temporary +from Lib.Statement import Statement, Instruction, regset_to_string +from Lib.CFG import CFG, Block +import copy + + +class LivenessDataFlow: + + def __init__(self, function, debug=False): + self._function: CFG = function + self._debug = debug + # Live Operands at input and output of blocks + self._blockin: Dict[Block, Set[Operand]] = {} + self._blockout: Dict[Block, Set[Operand]] = {} + # Live Operands at outputs of instructions + self._liveout: Dict[tuple[Block, Statement], Set[Operand]] = {} + + def run(self): + self.set_gen_kill() + if self._debug: + self.print_gen_kill() + + self.run_dataflow_analysis() + if self._debug: + self.print_map_in_out() + + self.fill_liveout() + + def set_gen_kill(self): + """Set the _gen and _kill field for each block in the function.""" + for blk in self._function.get_blocks(): + self.set_gen_kill_in_block(blk) + + def set_gen_kill_in_block(self, block: Block) -> None: + gen = set() + kill = set() + for i in block.get_all_statements(): + # Reminder: '|' is set union, '-' is subtraction. + raise NotImplementedError() + block._gen = gen + block._kill = kill + + def run_dataflow_analysis(self): + """Run the dataflow liveness analysis, i.e. compute self._blockin and + self._blockout based on the ._kill and ._gen fields of individual + instructions.""" + if self._debug: + print("Dataflow Analysis") + # initialisation of all blockout,blockin sets, and def = kill + for blk in self._function.get_blocks(): + self._blockin[blk] = set() + self._blockout[blk] = set() + stable = False + while not stable: + # Iterate until fixpoint : + # make calls to self._function.dataflow_one_step + stable = True # CHANGE + # TODO (lab5) ! (perform iterations until fixpoint). + + def dataflow_one_step(self): + """Run one iteration of the dataflow analysis. This function is meant + to be run iteratively until fixpoint.""" + for blk in self._function.get_blocks(): + self._blockout[blk] = set() + for child_label in blk.get_terminator().targets(): + child = self._function.get_block(child_label) + self._blockout[blk] = self._blockout[blk] | self._blockin[child] + + self._blockin[blk] = (self._blockout[blk] - blk._kill) | blk._gen + + def fill_liveout(self): + """Propagate the information from blockout/blockin inside the block + to get liveset instruction by instructions.""" + for blk in self._function.get_blocks(): + liveset = self._blockout[blk] + for instr in reversed(blk.get_all_statements()): + self._liveout[blk, instr] = liveset + liveset = (liveset - set(instr.defined())) | set(instr.used()) + + def print_gen_kill(self): # pragma: no cover + print("Dataflow Analysis, Initialisation") + for i, block in enumerate(self._function.get_blocks()): + print("block " + str(block._label), ":", i) + print("gen: " + regset_to_string(block._gen)) + print("kill: " + regset_to_string(block._kill) + "\n") + + def print_map_in_out(self): # pragma: no cover + """Print in/out sets, useful for debug!""" + print("In: {" + + ", ".join(str(x.get_label()) + ": " + + regset_to_string(self._blockin[x]) + for x in self._blockin.keys()) + + "}") + print("Out: {" + + ", ".join(str(x.get_label()) + ": " + + regset_to_string(self._blockout[x]) + for x in self._blockout.keys()) + + "}") diff --git a/MiniC/TP05/LivenessSSA.py b/MiniC/TP05/LivenessSSA.py new file mode 100644 index 0000000..f59dcca --- /dev/null +++ b/MiniC/TP05/LivenessSSA.py @@ -0,0 +1,81 @@ +from typing import Dict, Set, Tuple +from Lib.Operands import Temporary +from Lib.Statement import Statement, regset_to_string +from Lib.CFG import Block, CFG +from Lib.PhiNode import PhiNode + + +class LivenessSSA: + """Liveness Analysis on a CFG under SSA Form.""" + + def __init__(self, cfg: CFG, debug=False): + self._cfg: CFG = cfg + self._debug: bool = debug + # Temporary already propagated, by Block + self._seen: Dict[Block, Set[Temporary]] = dict() + # Live Temporary at outputs of Statement + self._liveout: Dict[tuple[Block, Statement], Set[Temporary]] = dict() + + def run(self) -> None: + """Compute the liveness: fill out self._seen and self._liveout.""" + # Initialization + for block in self._cfg.get_blocks(): + self._seen[block] = set() + for instr in block.get_all_statements(): + self._liveout[block, instr] = set() + # Start the used-defined chains with backward propagation of liveness information + for var, uses in self.gather_uses().items(): + for block, pos in uses: + self.livein_at_instruction(block, pos, var) + # Add conflicts on phis + self.conflict_on_phis() + # Final debugging print + if self._debug: + self.print_map_in_out() + + def livein_at_instruction(self, block: Block, pos: int, var: Temporary) -> None: + """Backward propagation of liveness information at the beginning of an instruction.""" + raise NotImplementedError("LivenessSSA") # TODO (Lab 5b, Exercise 1) + + def liveout_at_instruction(self, block: Block, pos: int, var: Temporary) -> None: + """Backward propagation of liveness information at the end of an instruction.""" + instr = block.get_all_statements()[pos] + raise NotImplementedError("LivenessSSA") # TODO (Lab 5b, Exercise 1) + + def liveout_at_block(self, block: Block, var: Temporary) -> None: + """Backward propagation of liveness information at the end of a block.""" + raise NotImplementedError("LivenessSSA") # TODO (Lab 5b, Exercise 1) + + def gather_uses(self) -> Dict[Temporary, Set[Tuple[Block, int]]]: + """ + Return a dictionnary giving for each variable the set of statements using it, + with a statement identified by its block and its position inside the latter. + Phi instructions are at the beginning of their block, while a Terminator is at + the last position of its block. + """ + uses: Dict[Temporary, Set[Tuple[Block, int]]] = dict() + for block in self._cfg.get_blocks(): + for pos, instr in enumerate(block.get_all_statements()): + # Variables used by a statement `s` are `s.used()` + for var in instr.used(): + if isinstance(var, Temporary): + # Already computed uses of the var if any, otherwise the empty set + var_uses = uses.get(var, set()) + # Add for a statement its block and its position inside to the uses of var + uses[var] = var_uses.union({(block, pos)}) + return uses + + def conflict_on_phis(self) -> None: + """Ensures that variables defined by φ instructions are in conflict with one-another.""" + raise NotImplementedError("LivenessSSA") # TODO (Lab 5b, Exercise 1) + + def print_map_in_out(self) -> None: # pragma: no cover + """Print live out sets at each instruction, group by block, useful for debugging!""" + print("Liveout: [") + for block in self._cfg.get_blocks(): + print("Block " + str(block.get_label()) + ": {\n " + + ",\n ".join("\"{}\": {}" + .format(instr, regset_to_string(self._liveout[block, instr])) + for instr in block.get_all_statements()) + + "}") + print("]") diff --git a/MiniC/TP05/SequentializeMoves.py b/MiniC/TP05/SequentializeMoves.py new file mode 100644 index 0000000..7ab786e --- /dev/null +++ b/MiniC/TP05/SequentializeMoves.py @@ -0,0 +1,60 @@ +""" +CAP, SSA Intro, Elimination and Optimisations +Helper functions to convert a CFG out of SSA Form +for the Smart Allocator. +""" + +from typing import List, Set, Tuple +from Lib import RiscV +from Lib.Graphes import DiGraph +from Lib.CFG import BlockInstr +from Lib.Operands import Register, Offset, DataLocation, S + + +def generate_smart_move(dest: DataLocation, src: DataLocation) -> List[BlockInstr]: + """ + Generate a list of move, store and load instructions, depending on + whether the operands are registers or memory locations. + This is an helper function for `sequentialize_moves`. + """ + instr: List[BlockInstr] = [] + # TODO Compute the moves (Lab 5b, Exercise 4) + raise NotImplementedError("generate_smart_move") + return instr + + +def sequentialize_moves(parallel_moves: Set[Tuple[DataLocation, DataLocation]] + ) -> List[BlockInstr]: + """ + Take a set of parallel moves represented as (destination, source) pairs, + and return a list of sequential moves which respect the cycles. + Use the register `tmp` S2 for the cycles. + Return a corresponding list of RiscV instructions. + This is an helper function called during SSA exit. + """ + tmp: Register = S[2] # S2 is not a general purpose register + # Build the graph of the moves + move_graph: DiGraph = DiGraph() + for dest, src in parallel_moves: + move_graph.add_edge((src, dest)) + # List for the sequentialized moves to do + # Convention: in moves we put (dest, src) for each move + moves: List[Tuple[DataLocation, DataLocation]] = [] + # First iteratively remove all the vetices without successors + vars_without_successor = {src + for src, dests in move_graph.neighbourhoods() + if len(dests) == 0} + while vars_without_successor: + # TODO Remove the leaves iteratively (Lab 5b, Exercise 4) + raise NotImplementedError("sequentialize_moves: leaves") + # Then handle the cycles + cycles: List = move_graph.connected_components() + for cycle in cycles: + # TODO Handle each cycle (Lab 5b, Exercise 4) + raise NotImplementedError("sequentialize_moves: cycles") + # Transform the moves to do in actual RiscV instructions + moves_instr: List[BlockInstr] = [] + for dest, src in moves: + instrs = generate_smart_move(dest, src) + moves_instr.extend(instrs) + return moves_instr diff --git a/MiniC/TP05/SmartAllocator.py b/MiniC/TP05/SmartAllocator.py new file mode 100644 index 0000000..b3fe819 --- /dev/null +++ b/MiniC/TP05/SmartAllocator.py @@ -0,0 +1,99 @@ +from typing import List, Dict +from Lib.Errors import MiniCInternalError +from Lib.Operands import Temporary, Operand, S, Offset, DataLocation, GP_REGS +from Lib.Statement import Instruction +from Lib.Allocator import Allocator +from Lib.FunctionData import FunctionData +from Lib import RiscV +from Lib.Graphes import Graph # For Graph coloring utility functions + + +class SmartAllocator(Allocator): + + _igraph: Graph # interference graph + + def __init__(self, fdata: FunctionData, basename: str, liveness, + debug=False, debug_graphs=False): + self._liveness = liveness + self._basename: str = basename + self._debug: bool = debug + self._debug_graphs: bool = debug_graphs + super().__init__(fdata) + + def replace(self, old_instr: Instruction) -> List[Instruction]: + """ + Replace Temporary operands with the corresponding allocated + physical register (Register) OR memory location (Offset). + """ + before: List[Instruction] = [] + after: List[Instruction] = [] + new_args: List[Operand] = [] + # TODO (lab5): Compute before, after, subst. This is similar to what + # TODO (lab5): replace from the Naive and AllInMem Allocators do (Lab 4). + raise NotImplementedError("Smart Replace (lab5)") # TODO + # And now return the new list! + instr = old_instr.with_args(new_args) + return before + [instr] + after + + def prepare(self) -> None: + """ + Perform all preparatory steps related to smart register allocation: + + - Dataflow analysis to compute the liveness range of each + temporary. + - Interference graph construction. + - Graph coloring. + - Associating temporaries with actual locations. + """ + # Liveness analysis + self._liveness.run() + # Interference graph + self.build_interference_graph() + if self._debug_graphs: + print("Printing the interference graph") + self._igraph.print_dot(self._basename + "interference.dot") + # Smart Allocation via graph coloring + self.smart_alloc() + + def build_interference_graph(self) -> None: + """ + Build the interference graph (in self._igraph). + Vertices of the graph are temporaries, + and an edge exists between temporaries iff they are in conflict. + """ + self._igraph: Graph = Graph() + # Create a vertex for every temporary + # There may be temporaries the code does not use anymore, + # but it does not matter as they interfere with no one. + for v in self._fdata._pool.get_all_temps(): + self._igraph.add_vertex(v) + # Iterate over self._liveness._liveout (dictionary containing all + # live out temporaries for each instruction), and for each conflict use + # self._igraph.add_edge((t1, t2)) to add the corresponding edge. + raise NotImplementedError("build_interference_graph (lab5)") # TODO + + def smart_alloc(self) -> None: + """ + Allocates all temporaries via graph coloring. + Prints the colored graph if self._debug_graphs is True. + + Precondition: the interference graph _igraph must have been built. + """ + # Checking the interference graph has been built + if not self._igraph: + raise MiniCInternalError("Empty interference graph in the Smart Allocator") + # Coloring of the interference graph + coloringreg: Dict[Temporary, int] = self._igraph.color() + if self._debug_graphs: + print("coloring = " + str(coloringreg)) + self._igraph.print_dot(self._basename + "_colored.dot", coloringreg) + # Temporary -> DataLocation (Register or Offset) dictionary, + # specifying where a given Temporary should be allocated: + alloc_dict: Dict[Temporary, DataLocation] = dict() + # Use the coloring `coloringreg` to fill `alloc_dict`. + # Our version is less than 5 lines of code. + raise NotImplementedError("Allocation based on graph coloring (lab5)") # TODO + if self._debug: + print("Allocation:") + print(alloc_dict) + self._fdata._pool.set_temp_allocation(alloc_dict) diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun01.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun01.c new file mode 100644 index 0000000..fd23f80 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun01.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +int f(int x){ + int y ; + y = 42; + return y; +} + +int main(){ + int x ; + x = f(41, 41); + println_int(x); + return 0; +} + + +// EXITCODE 2 +// EXPECTED +// In function main: Line 11 col 6: wrong number of arguments in call to function f diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun02.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun02.c new file mode 100644 index 0000000..6bfea11 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun02.c @@ -0,0 +1,20 @@ +#include "printlib.h" + +int f(int x){ + int y ; + y = 42; + return y; +} + +int main(){ + int x ; + bool b; + b = true; + x = f(b); + println_int(x); + return 0; +} + +// EXITCODE 2 +// EXPECTED +// In function main: Line 13 col 6: type mismatch for method argument in call to function f: boolean and integer diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun03.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun03.c new file mode 100644 index 0000000..3d0b386 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun03.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +int f(int x){ + int y ; + y = 42; + return y; +} + +int main(){ + bool b; + b = f(12); + return 0; +} + + +// EXITCODE 2 +// EXPECTED +// In function main: Line 11 col 2: type mismatch for b: boolean and integer + diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun04.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun04.c new file mode 100644 index 0000000..e8a8549 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun04.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +int f(int x, bool b, int z); + +int main(){ + bool b; + b = f(12,1,2); + return 0; +} + +int f(int x, bool b, int z){ + int y ; + y = 42; + return y; +} + +// EXITCODE 2 +// EXPECTED +// In function main: Line 7 col 6: type mismatch for method argument in call to function f: integer and boolean diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun05.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun05.c new file mode 100644 index 0000000..1c37af6 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun05.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +int f(int x, bool b, int z); + +int main(){ + int b; + b = f(12,true,2); + return 0; +} + +int f(int x, bool b, int z){ + int y ; + y = 42; + return true; +} + +// EXITCODE 2 +// EXPECTED +// In function f: Line 11 col 0: type mismatch for return type of function f: integer and boolean diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_double.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_double.c new file mode 100644 index 0000000..19c6d57 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_double.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +int f(int x, bool x){ + int y ; + y = 42; + return y; +} + +int main(){ + int x ; + x = f(41, 41); + println_int(x); + return 0; +} + +// EXITCODE 2 +// EXPECTED +// In function f: Line 3 col 13: Parameter x already defined + diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_double02.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_double02.c new file mode 100644 index 0000000..e814bb0 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_double02.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +bool f(int x, bool b){ + int x ; + x = 42; + return b; +} + +int main(){ + int x ; + x = f(41, 41); + println_int(x); + return 0; +} + +// EXITCODE 2 +// EXPECTED +// In function f: Line 4 col 2: Variable x already declared + diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_doublefun.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_doublefun.c new file mode 100644 index 0000000..5fbc5d1 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_doublefun.c @@ -0,0 +1,21 @@ +#include "printlib.h" + +int f(int x, bool y); + +int f(int x, int y){ + int y ; + y = 42; + return y; +} + + +int main(){ + bool b; + b = f(12); + return 0; +} + + +// EXITCODE 2 +// EXPECTED +// In function f: Line 5 col 0: function f already declared with a different signature diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_doublefun02.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_doublefun02.c new file mode 100644 index 0000000..5df0e88 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_doublefun02.c @@ -0,0 +1,23 @@ +#include "printlib.h" + +int f(int x, bool y); + +int f(int x, bool y){ + return 2; +} + +int f(int x, bool y){ + return 0; +} + +int main(){ + bool b; + b = f(12); + return 0; +} + + +// EXITCODE 2 +// EXPECTED +// In function f: Line 9 col 0: function f already defined + diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_nb_args0.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_nb_args0.c new file mode 100644 index 0000000..b05426c --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_nb_args0.c @@ -0,0 +1,14 @@ +#include "printlib.h" + +bool bbb(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7, bool b8, bool b9){ + return b9; +} + +bool main() { + bool dummy; + return dummy; +} + +// EXITCODE 2 +// EXPECTED +// In function bbb: Line 3 col 0: function bbb declared with 10 > 8 arguments diff --git a/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_nb_args1.c b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_nb_args1.c new file mode 100644 index 0000000..489b046 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/bad_type_fun_nb_args1.c @@ -0,0 +1,17 @@ +#include "printlib.h" + +bool bbb(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7, bool b8, bool b9, bool b10); + +bool bbb(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7, bool b8, bool b9, bool b10){ + return b9; +} + +bool main() { + bool dummy; + dummy = bbb(true, true, true, true, true, true, true, true, true, false); + return dummy; +} + +// EXITCODE 2 +// EXPECTED +// In function bbb: Line 3 col 0: function bbb declared with 11 > 8 arguments diff --git a/MiniC/TP06/tests/provided/basic-functions/lib/_hello.c b/MiniC/TP06/tests/provided/basic-functions/lib/_hello.c new file mode 100644 index 0000000..37c7a00 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/lib/_hello.c @@ -0,0 +1,5 @@ +#include + +int print_hello() { + printf("Hello, world!\n"); +} diff --git a/MiniC/TP06/tests/provided/basic-functions/no_def.c b/MiniC/TP06/tests/provided/basic-functions/no_def.c new file mode 100644 index 0000000..6bf9e7e --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/no_def.c @@ -0,0 +1,7 @@ +int main() { + x = f(1); + return 0; +} +// EXITCODE 2 +// EXPECTED +// In function main: Line 2 col 6: Undefined function f diff --git a/MiniC/TP06/tests/provided/basic-functions/test_bool.c b/MiniC/TP06/tests/provided/basic-functions/test_bool.c new file mode 100644 index 0000000..b1eb7ae --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_bool.c @@ -0,0 +1,13 @@ +#include "printlib.h" + +bool bbb(bool b){ + return b; +} + +int main() { + bool dummy; + dummy = bbb(false); + return 0; +} + +// EXPECTED diff --git a/MiniC/TP06/tests/provided/basic-functions/test_dummy_forward.c b/MiniC/TP06/tests/provided/basic-functions/test_dummy_forward.c new file mode 100644 index 0000000..b65d97f --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_dummy_forward.c @@ -0,0 +1,14 @@ + + +int f() {return 42;} + +int f(); + +int main(){ + int dummy; + dummy = f(); + return 0; +} + +// EXPECTED +// EXITCODE 0 \ No newline at end of file diff --git a/MiniC/TP06/tests/provided/basic-functions/test_extern.c b/MiniC/TP06/tests/provided/basic-functions/test_extern.c new file mode 100644 index 0000000..ea606b3 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_extern.c @@ -0,0 +1,13 @@ +// Call to external functions + +int print_hello(); + +int main() { + int dummy; + dummy = print_hello(); + return 0; +} + +// EXPECTED +// Hello, world! +// LINKARGS $dir/lib/_hello.c diff --git a/MiniC/TP06/tests/provided/basic-functions/test_extern_asm.c b/MiniC/TP06/tests/provided/basic-functions/test_extern_asm.c new file mode 100644 index 0000000..02c9a5d --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_extern_asm.c @@ -0,0 +1,13 @@ +// Call to external functions written in assembly + +int print_42(); + +int main() { + int dummy; + dummy = print_42(); + return 0; +} + +// EXPECTED +// 42 +// LINKARGS $dir/lib/_print42.s diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_call01.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_call01.c new file mode 100644 index 0000000..c063a4e --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_call01.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +// Call of function with no parameter + +int f(int x){ + int y ; + y = 42; + return y; +} + +int main(){ + int val; + val = f(123); + println_int(val); + return 0; +} + +// EXPECTED +// 42 diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_call02.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_call02.c new file mode 100644 index 0000000..3fadf4f --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_call02.c @@ -0,0 +1,19 @@ +#include "printlib.h" + +// Call of function with a single parameter + +int f(int x){ + int y ; + y = 42; + return y; +} + +int main(){ + int val; + val = f(12); + println_int(val); + return 0; +} + +// EXPECTED +// 42 diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_call03.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_call03.c new file mode 100644 index 0000000..c55ac0f --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_call03.c @@ -0,0 +1,17 @@ +#include "printlib.h" + +// Call of function with two parameters + +int f(int x, int y){ + return x + y; +} + +int main(){ + int val; + val = f(12, 30); + println_int(val); + return 0; +} + +// EXPECTED +// 42 diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_call04.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_call04.c new file mode 100644 index 0000000..72d27b8 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_call04.c @@ -0,0 +1,17 @@ +#include "printlib.h" + +// Call of function with two parameters + +int f(int x, int y){ + return x + y; +} + +int main(){ + int val; + val = f(12, 31) - f(13,-12); + println_int(val); + return 0; +} + +// EXPECTED +// 42 diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_decl01.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_decl01.c new file mode 100644 index 0000000..306b64a --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_decl01.c @@ -0,0 +1,11 @@ +#include "printlib.h" + +// Forward declaration of function with no parameter + +int f(); + +int main(){ + return 0; +} + +// EXPECTED diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_decl02.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_decl02.c new file mode 100644 index 0000000..eb9e7e1 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_decl02.c @@ -0,0 +1,11 @@ +#include "printlib.h" + +// Forward declaration of function with a single parameter + +int f(int x); + +int main(){ + return 0; +} + +// EXPECTED diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_decl03.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_decl03.c new file mode 100644 index 0000000..f5e0b10 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_decl03.c @@ -0,0 +1,11 @@ +#include "printlib.h" + +// Forward declaration of function with two parameters + +int f(int x, bool y); + +int main(){ + return 0; +} + +// EXPECTED diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_def01.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_def01.c new file mode 100644 index 0000000..1c3fdbc --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_def01.c @@ -0,0 +1,15 @@ +#include "printlib.h" + +// Definition of function with a single parameter + +int f(int x){ + int y ; + y = 42; + return y; +} + +int main(){ + return 0; +} + +// EXPECTED diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_def02.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_def02.c new file mode 100644 index 0000000..d0f0505 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_def02.c @@ -0,0 +1,12 @@ +#include "printlib.h" + +// Declaration of a function with two parameters +int f(int x, bool y) { + return x; +} + +int main(){ + return 0; +} + +// EXPECTED diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_expr.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_expr.c new file mode 100644 index 0000000..7274fc9 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_expr.c @@ -0,0 +1,15 @@ +#include "printlib.h" + +int f(int x){ + return x + 1; +} + +int main() { + int dummy; + dummy = f(f(10) + f(100)); + println_int(dummy); + return 0; +} + +// EXPECTED +// 113 diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_fwd_def01.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_fwd_def01.c new file mode 100644 index 0000000..6baa980 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_fwd_def01.c @@ -0,0 +1,20 @@ +#include "printlib.h" + +// Definition of function with a single parameter +// with forward declaration, i.e. declaration here and definition after main +int f(int x); + +int main(){ + int z; + z = f(0); + return 0; +} + +int f(int x){ + int y ; + y = 42; + return y; +} + + +// EXPECTED diff --git a/MiniC/TP06/tests/provided/basic-functions/test_fun_ret01.c b/MiniC/TP06/tests/provided/basic-functions/test_fun_ret01.c new file mode 100644 index 0000000..f7e2600 --- /dev/null +++ b/MiniC/TP06/tests/provided/basic-functions/test_fun_ret01.c @@ -0,0 +1,10 @@ +#include "printlib.h" + +// Return statememnt with expression + +int main(){ + return 1 + 2; +} + +// EXPECTED +// EXECCODE 3 diff --git a/MiniC/TPoptim/OptimSSA.py b/MiniC/TPoptim/OptimSSA.py new file mode 100644 index 0000000..a015a1f --- /dev/null +++ b/MiniC/TPoptim/OptimSSA.py @@ -0,0 +1,427 @@ +""" +CAP, SSA Intro, Elimination and Optimisations +Optimisations on SSA. +""" + +from enum import Enum +from typing import List, Dict, Tuple, cast +from Lib.Errors import MiniCInternalError +from Lib.Operands import (Operand, Temporary, Immediate, A, ZERO) +from Lib.Statement import (Statement, Instruction, Label, AbsoluteJump) +from Lib.CFG import (BlockInstr, Terminator, Block, CFG) +from Lib.Terminator import (Return, BranchingTerminator) +from Lib.PhiNode import PhiNode +from Lib import RiscV + + +def div_rd_0(a: int, b: int) -> int: + """Division rounded towards 0 (integer division in Python rounds down).""" + return -(-a // b) if (a < 0) ^ (b < 0) else a // b + + +def mod_rd_0(a: int, b: int) -> int: + """Modulo rounded towards 0 (integer division in Python rounds down).""" + return -(-a % b) if (a < 0) ^ (b < 0) else a % b + + +class Lattice(Enum): + Bottom = 0 + Top = 1 + + +LATTICE_VALUE = int | Lattice # Type for our values: Bottom < int < Top + + +def join(v1: LATTICE_VALUE, v2: LATTICE_VALUE) -> LATTICE_VALUE: + """Compute the join of the two lattice values.""" + match v1, v2: + case Lattice.Top, _: + return Lattice.Top + case _, Lattice.Top: + return Lattice.Top + case Lattice.Bottom, _: + return v2 + case _, Lattice.Bottom: + return v1 + case _, _: # both int + if v1 == v2: + return v1 + else: + return Lattice.Top + + +def joinl(values: List[LATTICE_VALUE]) -> LATTICE_VALUE: + """Compute the join of the list of lattice values.""" + res = Lattice.Bottom + for v in values: + res = join(res, v) + return res + + +class CondConstantPropagation: + """ + Class that optimises a CFG under SSA form + following the algorithm "Sparse Conditionnal Constant Propagation". + """ + + cfg: CFG + # CFG under SSA form to optimise + + valueness: Dict[Operand, LATTICE_VALUE] + # Values of each variable v: + # valueness[v] = Lattice.Bottom if no evidence that v is assigned + # valueness[v] = n if we found evidence that only n is assigned to v + # valueness[v] = Lattice.Top if we found evidence that v is assigned + # to at least two different values + + executability: Dict[Tuple[Block | None, Block], bool] + # Exectuability of an edge (B, C): + # executability[B, C] = False if no evidence that the edge (B, C) can ever be executed + # executability[B, C] = True if (B, C) may be executed (over-approximation) + # There is an initial edge from None to the start block + + modified_flag: bool + # Flag to check if we reach the fixpoint + + debug: bool + # Print valueness and executability at each step if True + + all_vars: List[Operand] + # All the variables of the CFG + + all_blocks: List[Block] + # All the blocks of the CFG + + def __init__(self, cfg: CFG, debug: bool): + self.cfg = cfg + self.valueness = dict() + self.executability = dict() + self.debug = debug + self.all_vars = list(cfg.gather_defs().keys()) + self.all_blocks = cfg.get_blocks() + + # Initialisation of valueness and executability + for var in self.all_vars: + self.valueness[var] = Lattice.Bottom + for block in self.all_blocks: + for succ in cfg.out_blocks(block): + self.executability[block, succ] = False + # Add an initial edge from None to the start block + start_blk = self.cfg.get_block(self.cfg.get_start()) + self.executability[None, start_blk] = False + + def dump(self) -> None: # pragma: no cover + """ + For debug purposes: print valueness and executability. + """ + print("Valueness:") + for x, v in self.valueness.items(): + print("{0}: {1}".format(x, v)) + print("Executability:") + for (B, C), v in self.executability.items(): + print("{0} -> {1}: {2}".format(B.get_label() if B is not None else "", + C.get_label(), v)) + + def set_valueness(self, v: Operand, x: LATTICE_VALUE) -> None: + """ + Update the valueness of a variable `v` by performing a join with + its current value. + """ + old_x = self.valueness[v] + new_x = join(x, old_x) + if new_x != old_x: + self.modified_flag = True + self.valueness[v] = new_x + + def set_executability(self, B: Block | None, C: Block) -> None: + """ + Mark the edge from `B` to `C` as executable. + """ + old_x = self.executability[B, C] + if not old_x: + self.modified_flag = True + self.executability[B, C] = True + + def is_constant(self, op: Operand) -> bool: + """True if the value of `op` is constant.""" + return isinstance(self.valueness.get(op, None), int) + + def is_executable(self, B: Block) -> bool: + """True if the block `B` may be executed.""" + return B in (C for ((_, C), b) in self.executability.items() if b) + + def compute(self) -> None: + """ + Compute executability for all edges and valueness for all variables + using a fixpoint algorithm. + """ + # 1. For any v coming from outside the CFG (parameters, function calls), + # set valueness[v] = Top. These are exactly the registers of A. + for var in A: + self.valueness[var] = Lattice.Top + + # 2. The start block is executable, with an initial edge coming from None. + start_blk = self.cfg.get_block(self.cfg.get_start()) + self.set_executability(None, start_blk) + + # Start the fixpoint. + self.modified_flag = True + while self.modified_flag: + # Whenever executability or valueness is modified, + # modified_flag is set to True (see set_executability and set_valueness) + # so that the fixpoint continues. + self.modified_flag = False + if self.debug: + self.dump() + + # 3. For any executable block B with only one successor C, + # set executability[B, C] = True. + for B in self.all_blocks: + nexts = self.cfg.out_blocks(B) + if self.is_executable(B) and len(nexts) == 1: + C = nexts[0] + self.set_executability(B, C) + + for B in self.all_blocks: + if self.is_executable(B): + for stat in B.get_all_statements(): + self.propagate_in(B, stat) + + def propagate_in(self, B: Block, stat: Statement) -> None: + """ + Propagate valueness and executability to the given statement `stat` + located in the given executable block `B`. + See the `compute` function for more context. + """ + # 4. For any executable assignment v <- op (x, y), + # set valueness[v] = eval (op, x, y) + # TODO (Exercise 4) + + # 5. For any executable assignment v <- phi (x1, ..., xn), + # set valueness[v] = join(x1, .., xn) + # TODO (Exercise 6) + + # 6. For any executable conditional branch to blocks B1 and B2, + # set executability[B1] = True and/or executability[B2] = True + # depending on the valueness of its condition + # TODO (Exercise 6) + + def get_executable_srcs(self, B: Block, phi: PhiNode) -> List[Operand]: + """ + Given a phi node `phi` belonging to the block `B`, + return its operands coming from an executable edge. + """ + return [x for lbl, x in phi.get_srcs().items() + if self.executability[self.cfg.get_block(lbl), B]] + + def get_operands(self, ins: Instruction) -> List[LATTICE_VALUE]: + """ + Returns the valueness of the operands of the given instruction `ins`. + Also takes into account immediate values and the zero register. + """ + args: List[LATTICE_VALUE] = [] + for x in ins.used(): + if isinstance(x, Temporary): + args.append(self.valueness[x]) + elif isinstance(x, Immediate): + args.append(x._val) + elif (x == ZERO): + args.append(0) + elif isinstance(x, Label): + continue + else: + args.append(Lattice.Top) + return args + + def eval_arith_instr(self, ins: Instruction) -> LATTICE_VALUE: + """ + Computes the result of an arithmetic instruction in the valueness lattice, + from the valueness of its operands. + """ + args = self.get_operands(ins) + name: str = ins.ins + + if Lattice.Top in args: + return Lattice.Top + elif Lattice.Bottom in args: + return Lattice.Bottom + + args = cast(List[int], args) + if name == "add" or name == "addi": + return args[0] + args[1] + elif name == "mul": + return args[0] * args[1] + elif name == "div": + return div_rd_0(args[0], args[1]) + elif name == "rem": + return mod_rd_0(args[0], args[1]) + elif name == "sub": + return args[0] - args[1] + elif name == "and": + return args[0] & args[1] + elif name == "or": + return args[0] | args[1] + elif name == "xor" or name == "xori": + return args[0] ^ args[1] + elif name == "li": + assert (isinstance(ins.used()[0], Immediate)) + return args[0] + elif name == "mv": + return args[0] + + raise MiniCInternalError("Instruction modifying a temporary not in\ + ['add', 'addi', 'mul', 'div', 'rem',\ + 'sub', 'and', 'or', 'xor', 'xori', 'li', 'mv']") + + def eval_bool_instr(self, ins: BranchingTerminator) -> LATTICE_VALUE: + """ + Computes the result of the comparison of a branching instruction + in the valueness lattice, from the valueness of its operands. + """ + args = self.get_operands(ins) + name: str = ins.ins + + if Lattice.Top in args: + return Lattice.Top + elif Lattice.Bottom in args: + return Lattice.Bottom + + args = cast(List[int], args) + if name == "blt": + return args[0] < args[1] + elif name == "bgt": + return args[0] > args[1] + elif name == "beq": + return args[0] == args[1] + elif name == "bne": + return args[0] != args[1] + elif name == "ble": + return args[0] <= args[1] + elif name == "bge": + return args[0] >= args[1] + elif name == "beqz": + return args[0] == 0 + elif name == "bnez": + return args[0] != 0 + + raise MiniCInternalError("Condition of a CondJump not in ['blt',\ + 'bgt', 'beq', 'bne', 'ble', 'bge',\ + 'beqz', 'bnez']") + + def replacePhi(self, B: Block, ins: PhiNode) -> PhiNode: + """ + Replace a phi node that has constant operands + according to the valueness computation. + """ + to_remove: List[Label] = [] # List of block's labels with no executable edge to B + for Bi_label, xi in ins.get_srcs().items(): + Bi = self.cfg.get_block(Bi_label) + if self.executability[Bi, B]: + if self.is_constant(xi): + # Add a LI instruction in the block from where xi comes, + # at the end of its body (i.e. just before its Terminator), + # and replace xi by this new temporary + new_xi = self.cfg.fdata.fresh_tmp() + ins.srcs[Bi_label] = new_xi + imm = Immediate(self.valueness[xi]) + li_ins = RiscV.li(new_xi, imm) + Bi.add_instruction(li_ins) + else: + to_remove.append(Bi_label) + for Bi_label in to_remove: + del ins.srcs[Bi_label] + return ins + + def replaceInstruction(self, ins: BlockInstr) -> List[BlockInstr]: + """ + Replace an instruction that has constant operands + according to the valueness computation. + """ + # Add some LI instructions before the instruction `ins` + li_instrs: List[BlockInstr] = [] + # Replace the constant variables with the temporaries defined by the new LI instructions + subst: Dict[Operand, Operand] = {} + + # Compute `li_instrs` and `subst` + # TODO (Exercise 5) + + new_ins = ins.substitute(subst) + return li_instrs + [new_ins] + + def replaceTerminator(self, ins: Terminator) -> Tuple[List[BlockInstr], Terminator]: + """ + Replace a terminator that has constant operands + according to the valueness computation. + Return the list of LI instructions to do before, + and the new terminator. + """ + # Add some LI instructions at the end of the body of the block + li_instrs: List[BlockInstr] = [] + # Replace the constant variables with the temporaries defined by the new LI instructions + subst: Dict[Operand, Operand] = {} + + # Compute `li_instrs` and `subst` + # TODO (Exercise 5) + + new_ins = ins.substitute(subst) + return li_instrs, new_ins + + def rewriteCFG(self) -> None: + """Update the CFG.""" + # a. Whenever executability[B, C] = False, delete this edge + for (B, C) in [(B, C) for ((B, C), b) in self.executability.items() + if not b and B is not None]: + # Remove the edge + self.cfg.remove_edge(B, C) + # Update the corresponding terminator + targets = B.get_terminator().targets() + targets.remove(C.get_label()) + if len(targets) == 0: + B.set_terminator(Return()) + elif len(targets) == 1: + B.set_terminator(AbsoluteJump(targets[0])) + else: + raise MiniCInternalError( + "rewriteCFG: A terminator has more than 2 targets: {}" + .format(targets + [C.get_label()])) + # b. Whenever valueness[x] = c, substitute c for x and delete assignment to x + for block in self.all_blocks: + if self.is_executable(block): + new_phis: List[PhiNode] = [] + for ins in block.get_phis(): + assert (isinstance(ins, PhiNode)) + v = ins.defined()[0] + if self.is_constant(v): + # We do not keep instructions defining operands of constant values + continue + else: + new_phis.append(self.replacePhi(block, ins)) + new_instrs: List[BlockInstr] = [] + for ins in block.get_body(): + defs = ins.defined() + if len(defs) == 1 and self.is_constant(defs[0]): + # We do not keep instructions defining operands of constant values + continue + elif isinstance(ins, Instruction): + # We replace others instructions + new_instrs.extend(self.replaceInstruction(ins)) + else: + # We do nothing for comments + new_instrs.append(ins) + term_instrs, new_term = self.replaceTerminator(block.get_terminator()) + block.set_phis(cast(List[Statement], new_phis)) + block._instructions = new_instrs + term_instrs + block.set_terminator(new_term) + # c. Whenever a block B is not executable, delete B + # There are no edge implicating B, for such an edge would not be + # executable, whence would have been deleted beforehand + for block in self.all_blocks: + if not self.is_executable(block): + del self.cfg._blocks[block.get_label()] + + +def OptimSSA(cfg: CFG, debug: bool) -> None: + """Optimise a CFG under SSA form.""" + optim = CondConstantPropagation(cfg, debug) + optim.compute() + optim.rewriteCFG() diff --git a/MiniC/TPoptim/tests/provided/example_lecture.c b/MiniC/TPoptim/tests/provided/example_lecture.c new file mode 100644 index 0000000..9cf1192 --- /dev/null +++ b/MiniC/TPoptim/tests/provided/example_lecture.c @@ -0,0 +1,23 @@ +#include "printlib.h" + +int main() { + int i, j, k; + i = 1; + j = 1; + k = 0; + while (k < 100) { + if (j < 20) { + j = i; + k = k+1; + } + else { + j = k; + k = k+2; + } + } + println_int(j); + return 0; +} + +// EXPECTED +// 1 diff --git a/MiniC/TPoptim/tests/provided/no_loop_constant.c b/MiniC/TPoptim/tests/provided/no_loop_constant.c new file mode 100644 index 0000000..12ef47c --- /dev/null +++ b/MiniC/TPoptim/tests/provided/no_loop_constant.c @@ -0,0 +1,12 @@ +#include "printlib.h" + +int main() { + int i, j; + i = 1; + j = i; + println_int(j); + return 0; +} + +// EXPECTED +// 1 diff --git a/MiniC/test_codegen.py b/MiniC/test_codegen.py new file mode 100755 index 0000000..05228cb --- /dev/null +++ b/MiniC/test_codegen.py @@ -0,0 +1,157 @@ +#! /usr/bin/env python3 + +import os +import sys +import pytest +import glob +from test_expect_pragma import ( + TestExpectPragmas, TestCompiler, + cat + ) + +""" +Usage: + python3 test_codegen.py +(or make test) +""" + +""" +MIF08 and CAP, 2019 +Unit test infrastructure for testing code generation: +1) compare the actual output to the expected one (in comments) +2) compare the actual output to the one obtained by simulation +3) for different allocation algorithms +""" + +MINICC_OPTS = [] +if "MINICC_OPTS" in os.environ and os.environ["MINICC_OPTS"]: + MINICC_OPTS = os.environ["MINICC_OPTS"].split() +else: + MINICC_OPTS = ["--mode=codegen-cfg"] + +DISABLE_TYPECHECK = "--disable-typecheck" in MINICC_OPTS \ + or "--mode=parse" in MINICC_OPTS or "parse" in MINICC_OPTS +DISABLE_CODEGEN = "--mode=parse" in MINICC_OPTS or "--mode=typecheck" in MINICC_OPTS \ + or "parse" in MINICC_OPTS or "typecheck" in MINICC_OPTS + +HERE = os.path.dirname(os.path.realpath(__file__)) +if HERE == os.path.realpath('.'): + HERE = '.' +TEST_DIR = HERE +IMPLEM_DIR = HERE +SKIP_EXPECT = False +if 'SKIP_EXPECT' in os.environ: + SKIP_EXPECT = True + +MINIC_COMPILE = os.path.join(IMPLEM_DIR, 'MiniCC.py') + +ALL_FILES = [] +# tests for typing AND evaluation +ALL_FILES += glob.glob(os.path.join(TEST_DIR, 'TP04/tests/**/[a-zA-Z]*.c'), + recursive=True) + + +ALLOC_FILES = glob.glob(os.path.join(HERE, 'TP05/tests/**/*.c'), recursive=True) + +SKIP_NOT_IMPLEMENTED = False +if 'SKIP_NOT_IMPLEMENTED' in os.environ: + SKIP_NOT_IMPLEMENTED = True + +if 'TEST_FILES' in os.environ: + ALL_FILES = glob.glob(os.environ['TEST_FILES'], recursive=True) + +MINIC_EVAL = os.path.join( + HERE, '..', '..', 'TP03', 'MiniC-type-interpret', 'Main.py') + +# if 'COMPIL_MINIC_EVAL' in os.environ: +# MINIC_EVAL = os.environ['COMPIL_MINIC_EVAL'] +# else: +# MINIC_EVAL = os.path.join( +# HERE, '..', '..', 'TP03', 'MiniC-type-interpret', 'Main.py') + +if 'TEST_FILES' in os.environ: + ALLOC_FILES = ALL_FILES + ALL_IN_MEM_FILES = ALL_FILES + +ALL_IN_MEM_FILES = list(set(ALL_FILES) | set(ALLOC_FILES)) +if 'FILTER' in os.environ: + FILTER_FILES = glob.glob(os.path.join(HERE, os.environ['FILTER']), recursive=True) + ALL_FILES = list(set(FILTER_FILES) & set(ALL_FILES)) + ALLOC_FILES = list(set(FILTER_FILES) & set(ALLOC_FILES)) + ALL_IN_MEM_FILES = list(set(FILTER_FILES) & set(ALL_IN_MEM_FILES)) + +# Avoid duplicates +ALL_IN_MEM_FILES.sort() +ALL_FILES = list(set(ALL_FILES)) +ALL_FILES.sort() + +class TestCodeGen(TestExpectPragmas, TestCompiler): + DISABLE_CODEGEN = DISABLE_CODEGEN + SKIP_NOT_IMPLEMENTED = SKIP_NOT_IMPLEMENTED + MINIC_COMPILE = MINIC_COMPILE + MINICC_OPTS = MINICC_OPTS + + # Not in test_expect_pragma to get assertion rewritting + def assert_equal(self, actual, expected, compiler): + if DISABLE_CODEGEN and expected.exitcode in (0, 5): + # Compiler does not fail => no output expected + assert actual.output == "", \ + "Compiler unexpectedly generated some output with codegen disabled" + assert actual.exitcode == 0, \ + "Compiler unexpectedly failed with codegen disabled" + return + if DISABLE_TYPECHECK and expected.exitcode != 0: + # Test should fail at typecheck, and we don't do + # typechecking => nothing to check. + pytest.skip("Test that doesn't typecheck with --disable-typecheck") + assert actual.exitcode == expected.exitcode, \ + f"Exit code of the compiler ({compiler}) is incorrect" + if expected.output is not None and actual.output is not None: + assert actual.output == expected.output, \ + f"Output of the program is incorrect (using {compiler})." + assert actual.execcode == expected.execcode, \ + f"Exit code of the execution is incorrect (after compiling with {compiler})" + + @pytest.mark.parametrize('filename', ALL_FILES) + def test_expect(self, filename): + """Test the EXPECTED annotations in test files by launching the + program with GCC.""" + if SKIP_EXPECT: + pytest.skip("Skipping all test_expect because $SKIP_EXPECT is set.") + expect = self.get_expect(filename) + if expect.skip_test_expected: + pytest.skip("Skipping test_expect with GCC because " + "the test contains SKIP TEST EXPECTED") + if expect.exitcode != 0: + # GCC is more permissive than us, so trying to compile an + # incorrect program would bring us no information (it may + # compile, or fail with a different message...) + pytest.skip("Not testing the expected value for tests expecting exitcode!=0") + gcc_result = self.run_with_gcc(filename, expect) + self.assert_equal(gcc_result, expect, "GCC") + + @pytest.mark.parametrize('filename', ALL_FILES) + def test_naive_alloc(self, filename): + cat(filename) # For diagnosis + expect = self.get_expect(filename) + naive = self.compile_and_simulate(filename, expect, 'naive') + self.assert_equal(naive, expect, "MiniCC with naive alloc") + + @pytest.mark.parametrize('filename', ALL_IN_MEM_FILES) + def test_alloc_mem(self, filename): + cat(filename) # For diagnosis + expect = self.get_expect(filename) + actual = self.compile_and_simulate(filename, expect, 'all-in-mem') + self.assert_equal(actual, expect, "MiniCC with all-in-mem") + + @pytest.mark.parametrize('filename', ALL_IN_MEM_FILES) + def test_smart_alloc(self, filename): + """Generate code with smart allocation.""" + cat(filename) # For diagnosis + expect = self.get_expect(filename) + actual = self.compile_and_simulate(filename, expect, 'smart') + self.assert_equal(actual, expect, "MiniCC with smart alloc") + + +if __name__ == '__main__': + pytest.main(sys.argv) diff --git a/MiniC/test_interpreter.py b/MiniC/test_interpreter.py index 1da3fe2..9095ba3 100755 --- a/MiniC/test_interpreter.py +++ b/MiniC/test_interpreter.py @@ -5,7 +5,7 @@ import os import sys from test_expect_pragma import ( TestExpectPragmas, cat, - TestCompiler, filter_pathnames + TestCompiler ) HERE = os.path.dirname(os.path.realpath(__file__)) @@ -34,7 +34,8 @@ if 'TEST_FILES' in os.environ: MINIC_EVAL = os.path.join(IMPLEM_DIR, 'MiniCC.py') if 'FILTER' in os.environ: - ALL_FILES = filter_pathnames(ALL_FILES, os.environ['FILTER']) + FILTER_FILES = glob.glob(os.path.join(HERE, os.environ['FILTER']), recursive=True) + ALL_FILES = list(set(FILTER_FILES) & set(ALL_FILES)) class TestInterpret(TestExpectPragmas, TestCompiler): diff --git a/PLANNING.md b/PLANNING.md index 04b85dd..ba68dc8 100644 --- a/PLANNING.md +++ b/PLANNING.md @@ -43,7 +43,7 @@ _Academic first semester 2024-2025_ # Week 4: -- hammer: Lab 3: Monday 30/09/2024, 13h30-15h30. Room E001 (Samuel Humeau & Emma Nardino) +- :hammer: Lab 3: Monday 30/09/2024, 13h30-15h30. Room E001 (Samuel Humeau & Emma Nardino) * Interpreter & Typer [TP03](TP03/tp3.pdf). * Code in [TP03/](TP03/) and [MiniC/TP03/](MiniC/TP03/). @@ -51,3 +51,12 @@ _Academic first semester 2024-2025_ - :book: Course: Thursday 3/10/2024, 10h15-12h15. Amphi B (Gabriel Radanne) * CFG [slides in english](course/capmif_cours06_irs.pdf). + +# Week 5: + +- :hammer: Lab 4a: Monday 07/10/2024, 13h30-15h30. Room E001 (Samuel Humeau & Emma Nardino) + + * Syntax directed code generation [TP04](TP04/tp4a.pdf). + * Code in [MiniC/TP04/](MiniC/TP04/). + * Documentation [here](docs/html/index.html). + diff --git a/TP03/tp3.pdf b/TP03/tp3.pdf index 01f6575..84dc914 100644 Binary files a/TP03/tp3.pdf and b/TP03/tp3.pdf differ diff --git a/TP04/tp4a.pdf b/TP04/tp4a.pdf new file mode 100644 index 0000000..604e689 Binary files /dev/null and b/TP04/tp4a.pdf differ diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/html/.buildinfo b/docs/html/.buildinfo new file mode 100644 index 0000000..1f994e9 --- /dev/null +++ b/docs/html/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. +config: 486d1ff73ffb3f41d31651516deff8a8 +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/html/_modules/Lib/Allocator.html b/docs/html/_modules/Lib/Allocator.html new file mode 100644 index 0000000..988ec40 --- /dev/null +++ b/docs/html/_modules/Lib/Allocator.html @@ -0,0 +1,185 @@ + + + + + + Lib.Allocator — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for Lib.Allocator

+"""
+This file defines the base class :py:class:`Allocator`
+and the naïve implementation :py:class:`NaiveAllocator`.
+"""
+
+from Lib.Operands import Temporary, Operand, DataLocation, GP_REGS
+from Lib.Statement import Instruction
+from Lib.Errors import AllocationError
+from Lib.FunctionData import FunctionData
+from typing import Dict, List
+
+
+
[docs]class Allocator(): + """General base class for Naive, AllInMem and Smart Allocators. + Replace all temporaries in the code with actual data locations. + + Allocation is done in two steps: + + - First, :py:meth:`prepare` is responsible for calling + :py:meth:`Lib.Operands.TemporaryPool.set_temp_allocation` + with a mapping from temporaries to where they should actually be stored + (in registers or in memory). + - Then, :py:meth:`replace` is called for each instruction in order to + replace the temporary operands with the previously assigned locations + (and possibly add some instructions before or after). + Concretely, it returns a list of instructions that should replace the original + instruction. The actual iteration over all the instructions is handled transparently + by :py:meth:`Lib.LinearCode.LinearCode.iter_statements`. + """ + + _fdata: FunctionData + + def __init__(self, fdata: FunctionData): + self._fdata = fdata + +
[docs] def prepare(self) -> None: # pragma: no cover + pass
+ +
[docs] def replace(self, old_instr: Instruction) -> List[Instruction]: + """Transform an instruction with temporaries into a list of instructions.""" + return [old_instr]
+ +
[docs] def rewriteCode(self, listcode) -> None: + """Modify the code to replace temporaries with + registers or memory locations. + """ + listcode.iter_statements(self.replace)
+ + +
[docs]class NaiveAllocator(Allocator): + """Naive Allocator: try to assign a register to each temporary, + fails if there are more temporaries than registers. + """ + +
[docs] def replace(self, old_instr: Instruction) -> List[Instruction]: + """Replace Temporary operands with the corresponding allocated Register.""" + new_args: List[Operand] = [] + for arg in old_instr.args(): + if isinstance(arg, Temporary): + new_args.append(arg.get_alloced_loc()) + else: + new_args.append(arg) + new_instr = old_instr.with_args(new_args) + return [new_instr]
+ +
[docs] def prepare(self) -> None: + """Allocate all temporaries to registers. + Fail if there are too many temporaries.""" + regs = list(GP_REGS) # Get a writable copy + temp_allocation: Dict[Temporary, DataLocation] = dict() + for tmp in self._fdata._pool.get_all_temps(): + try: + reg = regs.pop() + except IndexError: + raise AllocationError( + "Too many temporaries ({}) for the naive allocation, sorry." + .format(len(self._fdata._pool.get_all_temps()))) + temp_allocation[tmp] = reg + self._fdata._pool.set_temp_allocation(temp_allocation)
+
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/_modules/Lib/Errors.html b/docs/html/_modules/Lib/Errors.html new file mode 100644 index 0000000..3664bb0 --- /dev/null +++ b/docs/html/_modules/Lib/Errors.html @@ -0,0 +1,124 @@ + + + + + + Lib.Errors — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for Lib.Errors

+
[docs]class MiniCRuntimeError(Exception): + pass
+ + +
[docs]class MiniCInternalError(Exception): + pass
+ + +
[docs]class MiniCUnsupportedError(Exception): + pass
+ + +
[docs]class MiniCTypeError(Exception): + pass
+ + +
[docs]class AllocationError(Exception): + pass
+
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/_modules/Lib/FunctionData.html b/docs/html/_modules/Lib/FunctionData.html new file mode 100644 index 0000000..a0ccdb2 --- /dev/null +++ b/docs/html/_modules/Lib/FunctionData.html @@ -0,0 +1,287 @@ + + + + + + Lib.FunctionData — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for Lib.FunctionData

+"""
+This file defines the base class :py:class:`FunctionData`,
+containing metadata on a RiscV function, as well as utility
+functions common to the different intermediate representations.
+"""
+
+from typing import (List, Callable, TypeVar)
+from Lib.Errors import AllocationError
+from Lib.Operands import (
+    Offset, Temporary, TemporaryPool,
+    S, T, FP)
+from Lib.Statement import (Statement, Instruction, Label, Comment)
+
+
+
[docs]class FunctionData: + """ + Stores some metadata on a RiscV function: + name of the function, label names, temporary variables + (using :py:class:`Lib.Operands.TemporaryPool`), + and div_by_zero label. + + This class is usually used indirectly through the + different intermediate representations we work with, + such as :py:attr:`Lib.LinearCode.LinearCode.fdata`. + """ + + _nblabel: int + _dec: int + _pool: TemporaryPool + _name: str + _label_div_by_zero: Label + + def __init__(self, name: str): + self._nblabel = -1 + self._dec = 0 + self._pool = TemporaryPool() + self._name = name + self._label_div_by_zero = self.fresh_label("div_by_zero") + +
[docs] def get_name(self) -> str: + """Return the name of the function.""" + return self._name
+ +
[docs] def fresh_tmp(self) -> Temporary: + """ + Return a new fresh Temporary, + which is added to the pool. + """ + return self._pool.fresh_tmp()
+ +
[docs] def fresh_offset(self) -> Offset: + """ + Return a new offset in the memory stack. + Offsets are decreasing relative to FP. + """ + self._dec = self._dec + 1 + # For ld or sd, an offset on 12 signed bits is expected + # Raise an error if the offset is too big + if -8 * self._dec < - 2 ** 11: + raise AllocationError( + "Offset given by the allocation too big to be manipulated ({}), sorry." + .format(self._dec)) + return Offset(FP, -8 * self._dec)
+ +
[docs] def get_offset(self) -> int: + """ + Return the current offset in the memory stack. + """ + return self._dec
+ + def _fresh_label_name(self, name) -> str: + """ + Return a new unique label name based on the given string. + """ + self._nblabel = self._nblabel + 1 + return name + "_" + str(self._nblabel) + "_" + self._name + +
[docs] def fresh_label(self, name) -> Label: + """ + Return a new label, with a unique name based on the given string. + """ + return Label(self._fresh_label_name(name))
+ +
[docs] def get_label_div_by_zero(self) -> Label: + return self._label_div_by_zero
+ + +_T = TypeVar("_T", bound=Statement) + + +def _iter_statements( + listIns: List[_T], f: Callable[[_T], List[_T]]) -> List[_T | Comment]: + """Iterate over instructions. + For each real instruction i (not label or comment), replace it + with the list of instructions given by f(i). + """ + newListIns: List[_T | Comment] = [] + for old_i in listIns: + # Do nothing for label or comment + if not isinstance(old_i, Instruction): + newListIns.append(old_i) + continue + new_i_list = f(old_i) + # Otherwise, replace the instruction by the list + # returned by f, with comments giving the replacement + newListIns.append(Comment("Replaced " + str(old_i))) + newListIns.extend(new_i_list) + return newListIns + + +def _print_code(listIns: List, fdata: FunctionData, output, + init_label=None, fin_label=None, fin_div0=False, comment=None) -> None: + """ + Please use print_code from LinearCode or CFG, not directly this one. + + Print the instructions from listIns, forming fdata, on output. + If init_label is given, add an initial jump to it before the generated code. + If fin_label is given, add it after the generated code. + If fin_div0 is given equal to true, add the code for returning an + error when dividing by 0, at the very end. + """ + # compute size for the local stack - do not forget to align by 16 + fo = fdata.get_offset() # allocate enough memory for stack + # Room for S_i (except S_0 which is fp) and T_i backup + fo += len(S[1:]) + len(T) + cardoffset = 8 * (fo + (0 if fo % 2 == 0 else 1)) + 16 + output.write( + "##Automatically generated RISCV code, MIF08 & CAP\n") + if comment is not None: + output.write("##{} version\n".format(comment)) + output.write("\n\n##prelude\n") + # We put an li t0, cardoffset in case it is greater than 2**11 + # We use t0 because it is caller-saved + output.write(""" + .text + .globl {0} +{0}: + li t0, {1} + sub sp, sp, t0 + sd ra, 0(sp) + sd fp, 8(sp) + add fp, sp, t0 +""".format(fdata.get_name(), cardoffset)) + # Stack in RiscV is managed with SP + if init_label is not None: + # Add a jump to init_label before the generated code. + output.write(""" + j {0} +""".format(init_label)) + output.write("\n\n##Generated Code\n") + # Generated code + for i in listIns: + i.printIns(output) + output.write("\n\n##postlude\n") + if fin_label is not None: + # Add fin_label after the generated code. + output.write(""" +{0}: +""".format(fin_label)) + # We put an li t0, cardoffset in case it is greater than 2**11 + # We use t0 because it is caller-saved + output.write(""" + ld ra, 0(sp) + ld fp, 8(sp) + li t0, {0} + add sp, sp, t0 + ret +""".format(cardoffset)) + if fin_div0: + # Add code for division by 0 at the end. + output.write(""" +{0}: + la a0, {0}_msg + call println_string + li a0, 1 + call exit +""".format(fdata._label_div_by_zero)) + # Add the data for the message of the division by 0 + output.write(""" +{0}_msg: .string "Division by 0" +""".format(fdata._label_div_by_zero)) +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/_modules/Lib/LinearCode.html b/docs/html/_modules/Lib/LinearCode.html new file mode 100644 index 0000000..85c1c47 --- /dev/null +++ b/docs/html/_modules/Lib/LinearCode.html @@ -0,0 +1,209 @@ + + + + + + Lib.LinearCode — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for Lib.LinearCode

+"""
+CAP, CodeGeneration, LinearCode API
+Classes for a RiscV linear code.
+"""
+
+from typing import List
+from Lib.Operands import (A0, Function, DataLocation)
+from Lib.Statement import (
+    Instru3A, AbsoluteJump, ConditionalJump, Comment, Label
+)
+from Lib.RiscV import (mv, call)
+from Lib.FunctionData import (FunctionData, _iter_statements, _print_code)
+
+
+CodeStatement = Comment | Label | Instru3A | AbsoluteJump | ConditionalJump
+
+
+
[docs]class LinearCode: + """ + Representation of a RiscV program as a list of instructions. + + :py:meth:`add_instruction` is repeatedly called in the codegen visitor + to build a complete list of RiscV instructions for the source program. + + The :py:attr:`fdata` member variable contains some meta-information + on the program, for instance to allocate a new temporary. + See :py:class:`Lib.FunctionData.FunctionData`. + + For debugging purposes, :py:meth:`print_code` allows to print + the RiscV program to a file. + """ + + """ + The :py:attr:`fdata` member variable contains some meta-information + on the program, for instance to allocate a new temporary. + See :py:class:`Lib.FunctionData.FunctionData`. + """ + fdata: FunctionData + + _listIns: List[CodeStatement] + + def __init__(self, name: str): + self._listIns = [] + self.fdata = FunctionData(name) + +
[docs] def add_instruction(self, i: CodeStatement) -> None: + """ + Utility function to add an instruction in the program. + + See also :py:mod:`Lib.RiscV` to generate relevant instructions. + """ + self._listIns.append(i)
+ +
[docs] def iter_statements(self, f) -> None: + """Iterate over instructions. + For each real instruction i (not label or comment), replace it + with the list of instructions given by f(i). + """ + new_list_ins = _iter_statements(self._listIns, f) + # TODO: we shoudn't need to split this assignment with intermediate + # variable new_list_ins, but at least pyright pyright 1.1.293 + # raises an error here if we don't. + self._listIns = new_list_ins
+ +
[docs] def get_instructions(self) -> List[CodeStatement]: + """Return the list of instructions of the program.""" + return self._listIns
+ + # each instruction has its own "add in list" version +
[docs] def add_label(self, s: Label) -> None: + """Add a label in the program.""" + return self.add_instruction(s)
+ +
[docs] def add_comment(self, s: str) -> None: + """Add a comment in the program.""" + self.add_instruction(Comment(s))
+ +
[docs] def add_instruction_PRINTLN_INT(self, reg: DataLocation) -> None: + """Print integer value, with newline. (see Expand)""" + # A print instruction generates the temp it prints. + self.add_instruction(mv(A0, reg)) + self.add_instruction(call(Function('println_int')))
+ + def __str__(self): + return '\n'.join(map(str, self._listIns)) + +
[docs] def print_code(self, output, comment=None) -> None: + """Outputs the RiscV program as text to a file at the given path.""" + _print_code(self._listIns, self.fdata, output, init_label=None, + fin_label=None, fin_div0=True, comment=comment)
+ +
[docs] def print_dot(self, filename: str, DF=None, view=False) -> None: # pragma: no cover + """Outputs the RiscV program as graph to a file at the given path.""" + # import graphviz here so that students who don't have it can still work on lab4 + from graphviz import Digraph + graph = Digraph() + # nodes + content = "" + for i in self._listIns: + content += str(i) + "\\l" + graph.node("Code", label=content, shape='rectangle') + # no edges + graph.render(filename, view=view)
+
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/_modules/Lib/Operands.html b/docs/html/_modules/Lib/Operands.html new file mode 100644 index 0000000..15133cc --- /dev/null +++ b/docs/html/_modules/Lib/Operands.html @@ -0,0 +1,385 @@ + + + + + + Lib.Operands — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for Lib.Operands

+"""
+This file defines the base class :py:class:`Operand`
+and its subclasses for different operands: :py:class:`Condition`,
+:py:class:`DataLocation` and :py:class:`Function`.
+
+The class :py:class:`DataLocation` itself has subclasses:
+:py:class:`Register`, :py:class:`Offset` for address in memory,
+:py:class:`Immediate` for constants and :py:class:`Temporary`
+for location not yet allocated.
+
+This file also define shortcuts for registers in RISCV.
+"""
+
+from typing import Dict, List
+from MiniCParser import MiniCParser
+from Lib.Errors import MiniCInternalError
+
+
+
[docs]class Operand(): + + pass
+ + +# signed version for riscv +all_ops = ['blt', 'bgt', 'beq', 'bne', 'ble', 'bge', 'beqz', 'bnez'] +opdict = {MiniCParser.LT: 'blt', MiniCParser.GT: 'bgt', + MiniCParser.LTEQ: 'ble', MiniCParser.GTEQ: 'bge', + MiniCParser.NEQ: 'bne', MiniCParser.EQ: 'beq'} +opnot_dict = {'bgt': 'ble', + 'bge': 'blt', + 'blt': 'bge', + 'ble': 'bgt', + 'beq': 'bne', + 'bne': 'beq', + 'beqz': 'bnez', + 'bnez': 'beqz'} + + +
[docs]class Condition(Operand): + """Condition, i.e. comparison operand for a CondJump. + + Example usage : + + - Condition('beq') = branch if equal. + - Condition(MiniCParser.LT) = branch if lower than. + - ... + + The constructor's argument shall be a string in the list all_ops, or a + comparison operator in MiniCParser.LT, MiniCParser.GT, ... (one of the keys + in opdict). + + A 'negate' method allows getting the negation of this condition. + """ + + _op: str + + def __init__(self, optype): + if optype in opdict: + self._op = opdict[optype] + elif str(optype) in all_ops: + self._op = str(optype) + else: + raise MiniCInternalError(f"Unsupported comparison operator {optype}") + +
[docs] def negate(self) -> 'Condition': + """Return the opposite condition.""" + return Condition(opnot_dict[self._op])
+ + def __str__(self): + return self._op
+ + +
[docs]class Function(Operand): + """Operand for build-in function call.""" + + _name: str + + def __init__(self, name: str): + self._name = name + + def __str__(self): + return self._name
+ + +
[docs]class DataLocation(Operand): + """ A Data Location is either a register, a temporary + or a place in memory (offset). + """ + + pass
+ + +# map for register shortcuts +reg_map = dict([(0, 'zero'), (1, 'ra'), (2, 'sp')] + # no (3, 'gp') nor (4, 'tp') + [(i+5, 't'+str(i)) for i in range(3)] + + [(8, 'fp'), (9, 's1')] + + [(i+10, 'a'+str(i)) for i in range(8)] + + [(i+18, 's'+str(i+2)) for i in range(10)] + + [(i+28, 't'+str(i+3)) for i in range(4)]) + + +
[docs]class Register(DataLocation): + """ A (physical) register.""" + + _number: int + + def __init__(self, number: int): + self._number = number + + def __repr__(self): + if self._number not in reg_map: + raise MiniCInternalError(f"Register number {self._number} should not be used") + else: + return ("{}".format(reg_map[self._number])) + + def __eq__(self, other): + return isinstance(other, Register) and self._number == other._number + + def __hash__(self): + return self._number
+ + +# Shortcuts for registers in RISCV +# Only integer registers + +#: Zero register +ZERO = Register(0) +#: +RA = Register(1) +#: +SP = Register(2) +#: Register not used for this course +GP = Register(3) +#: Register not used for this course +TP = Register(4) +#: +A = tuple(Register(i + 10) for i in range(8)) +#: +S = tuple(Register(i + 8) for i in range(2)) + tuple(Register(i + 18) for i in range(10)) +#: +T = tuple(Register(i + 5) for i in range(3)) + tuple(Register(i + 28) for i in range(4)) + + +#: +A0 = A[0] # function args/return Values: A0, A1 +#: +A1 = A[1] +#: Frame Pointer = Saved register 0 +FP = S[0] + +#: General purpose registers, usable for the allocator +GP_REGS = S[4:] + T # s0, s1, s2 and s3 are special + + +
[docs]class Offset(DataLocation): + """ Offset = address in memory computed with base + offset.""" + + _basereg: Register + _offset: int + + def __init__(self, basereg: Register, offset: int): + self._basereg = basereg + self._offset = offset + + def __repr__(self): + return ("{}({})".format(self._offset, self._basereg)) + +
[docs] def get_offset(self) -> int: + """Return the value of the offset.""" + return self._offset
+ + +
[docs]class Immediate(DataLocation): + """Immediate operand (integer).""" + + _val: int + + def __init__(self, val): + self._val = val + + def __str__(self): + return str(self._val)
+ + +
[docs]class Temporary(DataLocation): + """Temporary, a location that has not been allocated yet. + It will later be mapped to a physical register (Register) or to a memory location (Offset). + """ + + _number: int + _pool: 'TemporaryPool' + + def __init__(self, number: int, pool: 'TemporaryPool'): + self._number = number + self._pool = pool + + def __repr__(self): + return ("temp_{}".format(str(self._number))) + +
[docs] def get_alloced_loc(self) -> DataLocation: + """Return the DataLocation allocated to this Temporary.""" + return self._pool.get_alloced_loc(self)
+ + +
[docs]class TemporaryPool: + """Manage a pool of temporaries.""" + + _all_temps: List[Temporary] + _current_num: int + _allocation: Dict[Temporary, DataLocation] + + def __init__(self): + self._all_temps = [] + self._current_num = 0 + self._allocation = dict() + +
[docs] def get_all_temps(self) -> List[Temporary]: + """Return all the temporaries of the pool.""" + return self._all_temps
+ +
[docs] def get_alloced_loc(self, t: Temporary) -> DataLocation: + """Get the actual DataLocation allocated for the temporary t.""" + return self._allocation[t]
+ +
[docs] def add_tmp(self, t: Temporary): + """Add a temporary to the pool.""" + self._all_temps.append(t) + self._allocation[t] = t # While no allocation, return the temporary itself
+ +
[docs] def set_temp_allocation(self, allocation: Dict[Temporary, DataLocation]) -> None: + """Give a mapping from temporaries to actual registers. + The argument allocation must be a dict from Temporary to + DataLocation other than Temporary (typically Register or Offset). + Typing enforces that keys are Temporary and values are Datalocation. + We check the values are indeed not Temporary. + """ + for v in allocation.values(): + assert not isinstance(v, Temporary), ( + "Incorrect allocation scheme: value " + + str(v) + " is a Temporary.") + self._allocation = allocation
+ +
[docs] def fresh_tmp(self) -> Temporary: + """Give a new fresh Temporary and add it to the pool.""" + t = Temporary(self._current_num, self) + self._current_num += 1 + self.add_tmp(t) + return t
+ + +
[docs]class Renamer: + """Manage a renaming of temporaries.""" + + _pool: TemporaryPool + _env: Dict[Temporary, Temporary] + + def __init__(self, pool: TemporaryPool): + self._pool = pool + self._env = dict() + +
[docs] def fresh(self, t: Temporary) -> Temporary: + """Give a fresh rename for a Temporary.""" + new_t = self._pool.fresh_tmp() + self._env[t] = new_t + return new_t
+ +
[docs] def replace(self, t: Temporary) -> Temporary: + """Give the rename for a Temporary (which is itself if it is not renamed).""" + return self._env.get(t, t)
+ +
[docs] def defined(self, t: Temporary) -> bool: + """True if the Temporary is renamed.""" + return t in self._env
+ +
[docs] def copy(self): + """Give a copy of the Renamer.""" + r = Renamer(self._pool) + r._env = self._env.copy() + return r
+
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/_modules/Lib/RiscV.html b/docs/html/_modules/Lib/RiscV.html new file mode 100644 index 0000000..ca45afb --- /dev/null +++ b/docs/html/_modules/Lib/RiscV.html @@ -0,0 +1,198 @@ + + + + + + Lib.RiscV — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for Lib.RiscV

+"""
+MIF08, CAP, CodeGeneration, RiscV API
+Functions to define instructions.
+"""
+
+from Lib.Errors import MiniCInternalError
+from Lib.Operands import (Condition, Immediate, Operand, Function)
+from Lib.Statement import (Instru3A, AbsoluteJump, ConditionalJump, Label)
+
+
+
[docs]def call(function: Function) -> Instru3A: + """Function call.""" + return Instru3A('call', function)
+ + +
[docs]def jump(label: Label) -> AbsoluteJump: + """Unconditional jump to label.""" + return AbsoluteJump(label)
+ + +
[docs]def conditional_jump(label: Label, op1: Operand, cond: Condition, op2: Operand): + """Add a conditional jump to the code. + This is a wrapper around bge, bgt, beq, ... c is a Condition, like + Condition('bgt'), Condition(MiniCParser.EQ), ... + """ + return ConditionalJump(cond=cond, op1=op1, op2=op2, label=label)
+ + +
[docs]def add(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + return Instru3A("addi", dr, sr1, sr2orimm7) + else: + return Instru3A("add", dr, sr1, sr2orimm7)
+ + +
[docs]def mul(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + raise MiniCInternalError("Cant multiply by an immediate") + else: + return Instru3A("mul", dr, sr1, sr2orimm7)
+ + +
[docs]def div(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + raise MiniCInternalError("Cant divide by an immediate") + else: + return Instru3A("div", dr, sr1, sr2orimm7)
+ + +
[docs]def rem(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + raise MiniCInternalError("Cant divide by an immediate") + return Instru3A("rem", dr, sr1, sr2orimm7)
+ + +
[docs]def sub(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + if isinstance(sr2orimm7, Immediate): + raise MiniCInternalError("Cant substract by an immediate") + return Instru3A("sub", dr, sr1, sr2orimm7)
+ + +
[docs]def land(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + """And instruction (cannot be called `and` due to Python and).""" + return Instru3A("and", dr, sr1, sr2orimm7)
+ + +
[docs]def lor(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: + """Or instruction (cannot be called `or` due to Python or).""" + return Instru3A("or", dr, sr1, sr2orimm7)
+ + +
[docs]def xor(dr: Operand, sr1: Operand, sr2orimm7: Operand) -> Instru3A: # pragma: no cover + if isinstance(sr2orimm7, Immediate): + return Instru3A("xori", dr, sr1, sr2orimm7) + else: + return Instru3A("xor", dr, sr1, sr2orimm7)
+ + +
[docs]def li(dr: Operand, imm7: Immediate) -> Instru3A: + return Instru3A("li", dr, imm7)
+ + +
[docs]def mv(dr: Operand, sr: Operand) -> Instru3A: + return Instru3A("mv", dr, sr)
+ + +
[docs]def ld(dr: Operand, mem: Operand) -> Instru3A: + return Instru3A("ld", dr, mem)
+ + +
[docs]def sd(sr: Operand, mem: Operand) -> Instru3A: + return Instru3A("sd", sr, mem)
+
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/_modules/Lib/Statement.html b/docs/html/_modules/Lib/Statement.html new file mode 100644 index 0000000..d64c780 --- /dev/null +++ b/docs/html/_modules/Lib/Statement.html @@ -0,0 +1,384 @@ + + + + + + Lib.Statement — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for Lib.Statement

+"""
+The base class for RISCV ASM statements is :py:class:`Statement`.
+It is inherited by :py:class:`Comment`, :py:class:`Label`
+and :py:class:`Instruction`. In turn, :py:class:`Instruction`
+is inherited by :py:class:`Instru3A`
+(for regular non-branching 3-address instructions),
+:py:class:`AbsoluteJump` and :py:class:`ConditionalJump`.
+"""
+
+from dataclasses import dataclass
+from typing import (List, Dict, TypeVar)
+from Lib.Operands import (Operand, Renamer, Temporary, Condition)
+from Lib.Errors import MiniCInternalError
+
+
+
[docs]def regset_to_string(registerset) -> str: + """Utility function: pretty-prints a set of locations.""" + return "{" + ",".join(str(x) for x in registerset) + "}"
+ + +# Temporary until we can use Typing.Self in python 3.11 +TStatement = TypeVar("TStatement", bound="Statement") + + +
[docs]@dataclass(unsafe_hash=True) +class Statement: + """A Statement, which is an instruction, a comment or a label.""" + +
[docs] def defined(self) -> List[Operand]: + """Operands defined (written) in this instruction""" + return []
+ +
[docs] def used(self) -> List[Operand]: + """Operands used (read) in this instruction""" + return []
+ +
[docs] def substitute(self: TStatement, subst: Dict[Operand, Operand]) -> TStatement: + """Return a new instruction, cloned from this one, replacing operands + that appear as key in subst by their value.""" + raise Exception( + "substitute: Operands {} are not present in instruction {}" + .format(subst, self))
+ +
[docs] def with_args(self: TStatement, new_args: List[Operand]) -> TStatement: + """Return a new instruction, cloned from this one, where operands have + been replaced by new_args.""" + raise Exception( + "substitute: Operands {} are not present in instruction {}" + .format(new_args, self))
+ +
[docs] def printIns(self, stream): + """ + Print the statement on the given output. + Should never be called on the base class. + """ + raise NotImplementedError
+ + +
[docs]@dataclass(unsafe_hash=True) +class Comment(Statement): + """A comment.""" + comment: str + + def __str__(self): # use only for print_dot ! + return "# {}".format(self.comment) + +
[docs] def printIns(self, stream): + print(' # ' + self.comment, file=stream)
+ + +
[docs]@dataclass(unsafe_hash=True) +class Label(Statement, Operand): + """A label is both a Statement and an Operand.""" + name: str + + def __str__(self): + return ("lbl_{}".format(self.name)) + + def __repr__(self): + return ("{}".format(self.name)) + +
[docs] def printIns(self, stream): + print(str(self) + ':', file=stream)
+ + +
[docs]@dataclass(init=False) +class Instruction(Statement): + ins: str + _read_only: bool + +
[docs] def is_read_only(self): + """ + True if the instruction only reads from its operands. + + Otherwise, the first operand is considered as the destination + and others are source. + """ + return self._read_only
+ +
[docs] def rename(self, renamer: Renamer) -> None: + raise NotImplementedError
+ +
[docs] def args(self) -> List[Operand]: + """List of operands the instruction takes""" + raise NotImplementedError
+ +
[docs] def defined(self): + if self.is_read_only(): + defs = [] + else: + defs = [self.args()[0]] + return defs
+ +
[docs] def used(self) -> List[Operand]: + if self.is_read_only(): + uses = self.args() + else: + uses = self.args()[1:] + return uses
+ + def __str__(self): + s = self.ins + first = True + for arg in self.args(): + if first: + s += ' ' + str(arg) + first = False + else: + s += ', ' + str(arg) + return s + + def __hash__(self): + return hash((self.ins, *self.args())) + +
[docs] def printIns(self, stream): + """Print the instruction on the given output.""" + print(' ', str(self), file=stream)
+ + +
[docs]@dataclass(init=False) +class Instru3A(Instruction): + _args: List[Operand] + + def __init__(self, ins, *args: Operand): + # convention is to use lower-case in RISCV + self.ins = ins.lower() + self._args = list(args) + self._read_only = (self.ins == "call" + or self.ins == "ld" + or self.ins == "lw" + or self.ins == "lb") + if (self.ins.startswith("b") or self.ins == "j"): + raise MiniCInternalError + +
[docs] def args(self): + return self._args
+ +
[docs] def rename(self, renamer: Renamer): + old_replaced = dict() + for i, arg in enumerate(self._args): + if isinstance(arg, Temporary): + if i == 0 and not self.is_read_only(): + old_replaced[arg] = renamer.replace(arg) + new_t = renamer.fresh(arg) + elif arg in old_replaced.keys(): + new_t = old_replaced[arg] + else: + new_t = renamer.replace(arg) + self._args[i] = new_t
+ +
[docs] def substitute(self, subst: Dict[Operand, Operand]): + for op in subst: + if op not in self.args(): + raise Exception( + "substitute: Operand {} is not present in instruction {}" + .format(op, self)) + args = [subst.get(arg, arg) + if isinstance(arg, Temporary) else arg + for arg in self.args()] + return Instru3A(self.ins, *args)
+ +
[docs] def with_args(self, new_args: List[Operand]): + if len(new_args) != len(self._args): + raise Exception( + "substitute: Expected {} operands for {}, got {}." + .format(len(self._args), self, new_args)) + return Instru3A(self.ins, *new_args)
+ + def __hash__(self): + return hash(super)
+ + +
[docs]@dataclass(init=False) +class AbsoluteJump(Instruction): + """ An Absolute Jump is a specific kind of instruction""" + ins = "j" + label: Label + _read_only = True + + def __init__(self, label: Label): + self.label = label + +
[docs] def args(self) -> List[Operand]: + return [self.label]
+ +
[docs] def rename(self, renamer: Renamer): + pass
+ +
[docs] def substitute(self, subst: Dict[Operand, Operand]): + if subst != {}: + raise Exception( + "substitute: No possible substitution on instruction {}" + .format(self)) + return self
+ +
[docs] def with_args(self, new_args: List[Operand]): + if new_args != self.args(): + raise Exception( + "substitute: No possible substitution on instruction {}. Old args={}, new args={}" + .format(self, self.args(), new_args)) + return self
+ + def __hash__(self): + return hash(super) + +
[docs] def targets(self) -> List[Label]: + """Return the labels targetted by the AbsoluteJump.""" + return [self.label]
+ + +
[docs]@dataclass(init=False) +class ConditionalJump(Instruction): + """ A Conditional Jump is a specific kind of instruction""" + cond: Condition + label: Label + op1: Operand + op2: Operand + _read_only = True + + def __init__(self, cond: Condition, op1: Operand, op2: Operand, label: Label): + self.cond = cond + self.label = label + self.op1 = op1 + self.op2 = op2 + self.ins = str(self.cond) + +
[docs] def args(self): + return [self.op1, self.op2, self.label]
+ +
[docs] def rename(self, renamer: Renamer): + if isinstance(self.op1, Temporary): + self.op1 = renamer.replace(self.op1) + if isinstance(self.op2, Temporary): + self.op2 = renamer.replace(self.op2)
+ +
[docs] def substitute(self, subst: Dict[Operand, Operand]): + for op in subst: + if op not in self.args(): + raise Exception( + "substitute: Operand {} is not present in instruction {}" + .format(op, self)) + op1 = subst.get(self.op1, self.op1) if isinstance(self.op1, Temporary) \ + else self.op1 + op2 = subst.get(self.op2, self.op2) if isinstance(self.op2, Temporary) \ + else self.op2 + return ConditionalJump(self.cond, op1, op2, self.label)
+ +
[docs] def with_args(self, new_args: List[Operand]): + if len(new_args) != 3: + raise Exception( + "substitute: Expected 3 operands for {}, got {}." + .format(self, new_args)) + assert isinstance(new_args[2], Label) + label: Label = new_args[2] + return ConditionalJump(self.cond, new_args[0], new_args[1], label)
+ + def __hash__(self): + return hash(super)
+
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/_modules/index.html b/docs/html/_modules/index.html new file mode 100644 index 0000000..f394ee2 --- /dev/null +++ b/docs/html/_modules/index.html @@ -0,0 +1,112 @@ + + + + + + Overview: module code — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + +
  • +
  • +
+
+
+
+
+ +

All modules for which code is available

+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/_sources/api/Lib.Allocator.rst.txt b/docs/html/_sources/api/Lib.Allocator.rst.txt new file mode 100644 index 0000000..56cd133 --- /dev/null +++ b/docs/html/_sources/api/Lib.Allocator.rst.txt @@ -0,0 +1,7 @@ +Lib.Allocator module +==================== + +.. automodule:: Lib.Allocator + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/html/_sources/api/Lib.Errors.rst.txt b/docs/html/_sources/api/Lib.Errors.rst.txt new file mode 100644 index 0000000..501ff9d --- /dev/null +++ b/docs/html/_sources/api/Lib.Errors.rst.txt @@ -0,0 +1,7 @@ +Lib.Errors module +================= + +.. automodule:: Lib.Errors + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/html/_sources/api/Lib.FunctionData.rst.txt b/docs/html/_sources/api/Lib.FunctionData.rst.txt new file mode 100644 index 0000000..e5b13d0 --- /dev/null +++ b/docs/html/_sources/api/Lib.FunctionData.rst.txt @@ -0,0 +1,7 @@ +Lib.FunctionData module +======================= + +.. automodule:: Lib.FunctionData + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/html/_sources/api/Lib.LinearCode.rst.txt b/docs/html/_sources/api/Lib.LinearCode.rst.txt new file mode 100644 index 0000000..61f78c2 --- /dev/null +++ b/docs/html/_sources/api/Lib.LinearCode.rst.txt @@ -0,0 +1,7 @@ +Lib.LinearCode module +===================== + +.. automodule:: Lib.LinearCode + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/html/_sources/api/Lib.Operands.rst.txt b/docs/html/_sources/api/Lib.Operands.rst.txt new file mode 100644 index 0000000..1ce7eb9 --- /dev/null +++ b/docs/html/_sources/api/Lib.Operands.rst.txt @@ -0,0 +1,7 @@ +Lib.Operands module +=================== + +.. automodule:: Lib.Operands + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/html/_sources/api/Lib.RiscV.rst.txt b/docs/html/_sources/api/Lib.RiscV.rst.txt new file mode 100644 index 0000000..329c039 --- /dev/null +++ b/docs/html/_sources/api/Lib.RiscV.rst.txt @@ -0,0 +1,7 @@ +Lib.RiscV module +================ + +.. automodule:: Lib.RiscV + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/html/_sources/api/Lib.Statement.rst.txt b/docs/html/_sources/api/Lib.Statement.rst.txt new file mode 100644 index 0000000..067e6a4 --- /dev/null +++ b/docs/html/_sources/api/Lib.Statement.rst.txt @@ -0,0 +1,7 @@ +Lib.Statement module +==================== + +.. automodule:: Lib.Statement + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/html/_sources/api/Lib.rst.txt b/docs/html/_sources/api/Lib.rst.txt new file mode 100644 index 0000000..9de53f0 --- /dev/null +++ b/docs/html/_sources/api/Lib.rst.txt @@ -0,0 +1,24 @@ +Lib package +=========== + +Submodules +---------- + +.. toctree:: + :maxdepth: 4 + + Lib.Allocator + Lib.Errors + Lib.FunctionData + Lib.LinearCode + Lib.Operands + Lib.RiscV + Lib.Statement + +Module contents +--------------- + +.. automodule:: Lib + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/html/_sources/api/modules.rst.txt b/docs/html/_sources/api/modules.rst.txt new file mode 100644 index 0000000..6d3183e --- /dev/null +++ b/docs/html/_sources/api/modules.rst.txt @@ -0,0 +1,7 @@ +MiniC +===== + +.. toctree:: + :maxdepth: 4 + + Lib diff --git a/docs/html/_sources/index.rst.txt b/docs/html/_sources/index.rst.txt new file mode 100644 index 0000000..ebe38e6 --- /dev/null +++ b/docs/html/_sources/index.rst.txt @@ -0,0 +1,77 @@ +.. MiniC documentation master file, created by + sphinx-quickstart on Thu Feb 3 16:47:38 2022. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to MiniC's documentation! +================================= + +.. toctree:: + :maxdepth: 4 + :caption: Contents: + + Base library - Errors + Base library - Statement + Base library - RISC-V instructions + Base library - Operands + Base library - Function data + Base library - Graphs + Linear intermediate representation + Temporary allocation + Control Flow Graph - CFG and Basic blocks + Control Flow Graph - Terminators + SSA form - Dominance frontier + SSA form - Phi Nodes + +These pages document the various Python sources in the Lib/ +folder of MiniC. You should not have to edit them *at all*. + +Base library +------------ + +The :doc:`api/Lib.Statement` defines various classes that represent +RISC-V assembly statements, such as labels or 3-address instructions. + +We won't create objects of these classes directly very often. +Instead, to easily create such statements for standard RISC-V assembly instructions +and pseudo-instructions, we give you the :doc:`api/Lib.RiscV`. + +RISC-V instructions take arguments of various kinds, +as defined in the :doc:`api/Lib.Operands`. + +At some point, we will need some basic functions about oriented and non oriented graphs, +those are present in :doc:`api/Lib.Graphes`. + +Linear Intermediate representation +---------------------------------- + +The :doc:`api/Lib.LinearCode` allows to work with assembly source code +modeled as a list of statements. + +Temporary allocation +-------------------- + +Before implementing the all-in-memory allocator of lab 4a, +you should understand the naive allocator in the :doc:`api/Lib.Allocator`. + +Control Flow Graph Intermediate representation +---------------------------------------------- + +The classes for the CFG and its basic blocks are in the :doc:`api/Lib.CFG`. +Each block ends with a terminator, as documented in the :doc:`api/Lib.Terminator`. + +SSA form +-------- + +The translation of the CFG into SSA form makes use of dominance frontiers. +Functions to work with dominance are defined in the :doc:`api/Lib.Dominators`. + +Phi nodes, a special kind of statement that appears in CFGs in SSA form, +are defined in the :doc:`api/Lib.PhiNode`. + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/html/_static/basic.css b/docs/html/_static/basic.css new file mode 100644 index 0000000..7577acb --- /dev/null +++ b/docs/html/_static/basic.css @@ -0,0 +1,903 @@ +/* + * basic.css + * ~~~~~~~~~ + * + * Sphinx stylesheet -- basic theme. + * + * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +/* -- main layout ----------------------------------------------------------- */ + +div.clearer { + clear: both; +} + +div.section::after { + display: block; + content: ''; + clear: left; +} + +/* -- relbar ---------------------------------------------------------------- */ + +div.related { + width: 100%; + font-size: 90%; +} + +div.related h3 { + display: none; +} + +div.related ul { + margin: 0; + padding: 0 0 0 10px; + list-style: none; +} + +div.related li { + display: inline; +} + +div.related li.right { + float: right; + margin-right: 5px; +} + +/* -- sidebar --------------------------------------------------------------- */ + +div.sphinxsidebarwrapper { + padding: 10px 5px 0 10px; +} + +div.sphinxsidebar { + float: left; + width: 230px; + margin-left: -100%; + font-size: 90%; + word-wrap: break-word; + overflow-wrap : break-word; +} + +div.sphinxsidebar ul { + list-style: none; +} + +div.sphinxsidebar ul ul, +div.sphinxsidebar ul.want-points { + margin-left: 20px; + list-style: square; +} + +div.sphinxsidebar ul ul { + margin-top: 0; + margin-bottom: 0; +} + +div.sphinxsidebar form { + margin-top: 10px; +} + +div.sphinxsidebar input { + border: 1px solid #98dbcc; + font-family: sans-serif; + font-size: 1em; +} + +div.sphinxsidebar #searchbox form.search { + overflow: hidden; +} + +div.sphinxsidebar #searchbox input[type="text"] { + float: left; + width: 80%; + padding: 0.25em; + box-sizing: border-box; +} + +div.sphinxsidebar #searchbox input[type="submit"] { + float: left; + width: 20%; + border-left: none; + padding: 0.25em; + box-sizing: border-box; +} + + +img { + border: 0; + max-width: 100%; +} + +/* -- search page ----------------------------------------------------------- */ + +ul.search { + margin: 10px 0 0 20px; + padding: 0; +} + +ul.search li { + padding: 5px 0 5px 20px; + background-image: url(file.png); + background-repeat: no-repeat; + background-position: 0 7px; +} + +ul.search li a { + font-weight: bold; +} + +ul.search li p.context { + color: #888; + margin: 2px 0 0 30px; + text-align: left; +} + +ul.keywordmatches li.goodmatch a { + font-weight: bold; +} + +/* -- index page ------------------------------------------------------------ */ + +table.contentstable { + width: 90%; + margin-left: auto; + margin-right: auto; +} + +table.contentstable p.biglink { + line-height: 150%; +} + +a.biglink { + font-size: 1.3em; +} + +span.linkdescr { + font-style: italic; + padding-top: 5px; + font-size: 90%; +} + +/* -- general index --------------------------------------------------------- */ + +table.indextable { + width: 100%; +} + +table.indextable td { + text-align: left; + vertical-align: top; +} + +table.indextable ul { + margin-top: 0; + margin-bottom: 0; + list-style-type: none; +} + +table.indextable > tbody > tr > td > ul { + padding-left: 0em; +} + +table.indextable tr.pcap { + height: 10px; +} + +table.indextable tr.cap { + margin-top: 10px; + background-color: #f2f2f2; +} + +img.toggler { + margin-right: 3px; + margin-top: 3px; + cursor: pointer; +} + +div.modindex-jumpbox { + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 1em 0 1em 0; + padding: 0.4em; +} + +div.genindex-jumpbox { + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 1em 0 1em 0; + padding: 0.4em; +} + +/* -- domain module index --------------------------------------------------- */ + +table.modindextable td { + padding: 2px; + border-collapse: collapse; +} + +/* -- general body styles --------------------------------------------------- */ + +div.body { + min-width: 360px; + max-width: 800px; +} + +div.body p, div.body dd, div.body li, div.body blockquote { + -moz-hyphens: auto; + -ms-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} + +a.headerlink { + visibility: hidden; +} + +h1:hover > a.headerlink, +h2:hover > a.headerlink, +h3:hover > a.headerlink, +h4:hover > a.headerlink, +h5:hover > a.headerlink, +h6:hover > a.headerlink, +dt:hover > a.headerlink, +caption:hover > a.headerlink, +p.caption:hover > a.headerlink, +div.code-block-caption:hover > a.headerlink { + visibility: visible; +} + +div.body p.caption { + text-align: inherit; +} + +div.body td { + text-align: left; +} + +.first { + margin-top: 0 !important; +} + +p.rubric { + margin-top: 30px; + font-weight: bold; +} + +img.align-left, figure.align-left, .figure.align-left, object.align-left { + clear: left; + float: left; + margin-right: 1em; +} + +img.align-right, figure.align-right, .figure.align-right, object.align-right { + clear: right; + float: right; + margin-left: 1em; +} + +img.align-center, figure.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; +} + +img.align-default, figure.align-default, .figure.align-default { + display: block; + margin-left: auto; + margin-right: auto; +} + +.align-left { + text-align: left; +} + +.align-center { + text-align: center; +} + +.align-default { + text-align: center; +} + +.align-right { + text-align: right; +} + +/* -- sidebars -------------------------------------------------------------- */ + +div.sidebar, +aside.sidebar { + margin: 0 0 0.5em 1em; + border: 1px solid #ddb; + padding: 7px; + background-color: #ffe; + width: 40%; + float: right; + clear: right; + overflow-x: auto; +} + +p.sidebar-title { + font-weight: bold; +} + +nav.contents, +aside.topic, +div.admonition, div.topic, blockquote { + clear: left; +} + +/* -- topics ---------------------------------------------------------------- */ + +nav.contents, +aside.topic, +div.topic { + border: 1px solid #ccc; + padding: 7px; + margin: 10px 0 10px 0; +} + +p.topic-title { + font-size: 1.1em; + font-weight: bold; + margin-top: 10px; +} + +/* -- admonitions ----------------------------------------------------------- */ + +div.admonition { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; +} + +div.admonition dt { + font-weight: bold; +} + +p.admonition-title { + margin: 0px 10px 5px 0px; + font-weight: bold; +} + +div.body p.centered { + text-align: center; + margin-top: 25px; +} + +/* -- content of sidebars/topics/admonitions -------------------------------- */ + +div.sidebar > :last-child, +aside.sidebar > :last-child, +nav.contents > :last-child, +aside.topic > :last-child, +div.topic > :last-child, +div.admonition > :last-child { + margin-bottom: 0; +} + +div.sidebar::after, +aside.sidebar::after, +nav.contents::after, +aside.topic::after, +div.topic::after, +div.admonition::after, +blockquote::after { + display: block; + content: ''; + clear: both; +} + +/* -- tables ---------------------------------------------------------------- */ + +table.docutils { + margin-top: 10px; + margin-bottom: 10px; + border: 0; + border-collapse: collapse; +} + +table.align-center { + margin-left: auto; + margin-right: auto; +} + +table.align-default { + margin-left: auto; + margin-right: auto; +} + +table caption span.caption-number { + font-style: italic; +} + +table caption span.caption-text { +} + +table.docutils td, table.docutils th { + padding: 1px 8px 1px 5px; + border-top: 0; + border-left: 0; + border-right: 0; + border-bottom: 1px solid #aaa; +} + +th { + text-align: left; + padding-right: 5px; +} + +table.citation { + border-left: solid 1px gray; + margin-left: 1px; +} + +table.citation td { + border-bottom: none; +} + +th > :first-child, +td > :first-child { + margin-top: 0px; +} + +th > :last-child, +td > :last-child { + margin-bottom: 0px; +} + +/* -- figures --------------------------------------------------------------- */ + +div.figure, figure { + margin: 0.5em; + padding: 0.5em; +} + +div.figure p.caption, figcaption { + padding: 0.3em; +} + +div.figure p.caption span.caption-number, +figcaption span.caption-number { + font-style: italic; +} + +div.figure p.caption span.caption-text, +figcaption span.caption-text { +} + +/* -- field list styles ----------------------------------------------------- */ + +table.field-list td, table.field-list th { + border: 0 !important; +} + +.field-list ul { + margin: 0; + padding-left: 1em; +} + +.field-list p { + margin: 0; +} + +.field-name { + -moz-hyphens: manual; + -ms-hyphens: manual; + -webkit-hyphens: manual; + hyphens: manual; +} + +/* -- hlist styles ---------------------------------------------------------- */ + +table.hlist { + margin: 1em 0; +} + +table.hlist td { + vertical-align: top; +} + +/* -- object description styles --------------------------------------------- */ + +.sig { + font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; +} + +.sig-name, code.descname { + background-color: transparent; + font-weight: bold; +} + +.sig-name { + font-size: 1.1em; +} + +code.descname { + font-size: 1.2em; +} + +.sig-prename, code.descclassname { + background-color: transparent; +} + +.optional { + font-size: 1.3em; +} + +.sig-paren { + font-size: larger; +} + +.sig-param.n { + font-style: italic; +} + +/* C++ specific styling */ + +.sig-inline.c-texpr, +.sig-inline.cpp-texpr { + font-family: unset; +} + +.sig.c .k, .sig.c .kt, +.sig.cpp .k, .sig.cpp .kt { + color: #0033B3; +} + +.sig.c .m, +.sig.cpp .m { + color: #1750EB; +} + +.sig.c .s, .sig.c .sc, +.sig.cpp .s, .sig.cpp .sc { + color: #067D17; +} + + +/* -- other body styles ----------------------------------------------------- */ + +ol.arabic { + list-style: decimal; +} + +ol.loweralpha { + list-style: lower-alpha; +} + +ol.upperalpha { + list-style: upper-alpha; +} + +ol.lowerroman { + list-style: lower-roman; +} + +ol.upperroman { + list-style: upper-roman; +} + +:not(li) > ol > li:first-child > :first-child, +:not(li) > ul > li:first-child > :first-child { + margin-top: 0px; +} + +:not(li) > ol > li:last-child > :last-child, +:not(li) > ul > li:last-child > :last-child { + margin-bottom: 0px; +} + +ol.simple ol p, +ol.simple ul p, +ul.simple ol p, +ul.simple ul p { + margin-top: 0; +} + +ol.simple > li:not(:first-child) > p, +ul.simple > li:not(:first-child) > p { + margin-top: 0; +} + +ol.simple p, +ul.simple p { + margin-bottom: 0; +} + +aside.footnote > span, +div.citation > span { + float: left; +} +aside.footnote > span:last-of-type, +div.citation > span:last-of-type { + padding-right: 0.5em; +} +aside.footnote > p { + margin-left: 2em; +} +div.citation > p { + margin-left: 4em; +} +aside.footnote > p:last-of-type, +div.citation > p:last-of-type { + margin-bottom: 0em; +} +aside.footnote > p:last-of-type:after, +div.citation > p:last-of-type:after { + content: ""; + clear: both; +} + +dl.field-list { + display: grid; + grid-template-columns: fit-content(30%) auto; +} + +dl.field-list > dt { + font-weight: bold; + word-break: break-word; + padding-left: 0.5em; + padding-right: 5px; +} + +dl.field-list > dd { + padding-left: 0.5em; + margin-top: 0em; + margin-left: 0em; + margin-bottom: 0em; +} + +dl { + margin-bottom: 15px; +} + +dd > :first-child { + margin-top: 0px; +} + +dd ul, dd table { + margin-bottom: 10px; +} + +dd { + margin-top: 3px; + margin-bottom: 10px; + margin-left: 30px; +} + +dl > dd:last-child, +dl > dd:last-child > :last-child { + margin-bottom: 0; +} + +dt:target, span.highlighted { + background-color: #fbe54e; +} + +rect.highlighted { + fill: #fbe54e; +} + +dl.glossary dt { + font-weight: bold; + font-size: 1.1em; +} + +.versionmodified { + font-style: italic; +} + +.system-message { + background-color: #fda; + padding: 5px; + border: 3px solid red; +} + +.footnote:target { + background-color: #ffa; +} + +.line-block { + display: block; + margin-top: 1em; + margin-bottom: 1em; +} + +.line-block .line-block { + margin-top: 0; + margin-bottom: 0; + margin-left: 1.5em; +} + +.guilabel, .menuselection { + font-family: sans-serif; +} + +.accelerator { + text-decoration: underline; +} + +.classifier { + font-style: oblique; +} + +.classifier:before { + font-style: normal; + margin: 0 0.5em; + content: ":"; + display: inline-block; +} + +abbr, acronym { + border-bottom: dotted 1px; + cursor: help; +} + +/* -- code displays --------------------------------------------------------- */ + +pre { + overflow: auto; + overflow-y: hidden; /* fixes display issues on Chrome browsers */ +} + +pre, div[class*="highlight-"] { + clear: both; +} + +span.pre { + -moz-hyphens: none; + -ms-hyphens: none; + -webkit-hyphens: none; + hyphens: none; + white-space: nowrap; +} + +div[class*="highlight-"] { + margin: 1em 0; +} + +td.linenos pre { + border: 0; + background-color: transparent; + color: #aaa; +} + +table.highlighttable { + display: block; +} + +table.highlighttable tbody { + display: block; +} + +table.highlighttable tr { + display: flex; +} + +table.highlighttable td { + margin: 0; + padding: 0; +} + +table.highlighttable td.linenos { + padding-right: 0.5em; +} + +table.highlighttable td.code { + flex: 1; + overflow: hidden; +} + +.highlight .hll { + display: block; +} + +div.highlight pre, +table.highlighttable pre { + margin: 0; +} + +div.code-block-caption + div { + margin-top: 0; +} + +div.code-block-caption { + margin-top: 1em; + padding: 2px 5px; + font-size: small; +} + +div.code-block-caption code { + background-color: transparent; +} + +table.highlighttable td.linenos, +span.linenos, +div.highlight span.gp { /* gp: Generic.Prompt */ + user-select: none; + -webkit-user-select: text; /* Safari fallback only */ + -webkit-user-select: none; /* Chrome/Safari */ + -moz-user-select: none; /* Firefox */ + -ms-user-select: none; /* IE10+ */ +} + +div.code-block-caption span.caption-number { + padding: 0.1em 0.3em; + font-style: italic; +} + +div.code-block-caption span.caption-text { +} + +div.literal-block-wrapper { + margin: 1em 0; +} + +code.xref, a code { + background-color: transparent; + font-weight: bold; +} + +h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { + background-color: transparent; +} + +.viewcode-link { + float: right; +} + +.viewcode-back { + float: right; + font-family: sans-serif; +} + +div.viewcode-block:target { + margin: -1px -10px; + padding: 0 10px; +} + +/* -- math display ---------------------------------------------------------- */ + +img.math { + vertical-align: middle; +} + +div.body div.math p { + text-align: center; +} + +span.eqno { + float: right; +} + +span.eqno a.headerlink { + position: absolute; + z-index: 1; +} + +div.math:hover a.headerlink { + visibility: visible; +} + +/* -- printout stylesheet --------------------------------------------------- */ + +@media print { + div.document, + div.documentwrapper, + div.bodywrapper { + margin: 0 !important; + width: 100%; + } + + div.sphinxsidebar, + div.related, + div.footer, + #top-link { + display: none; + } +} \ No newline at end of file diff --git a/docs/html/_static/css/badge_only.css b/docs/html/_static/css/badge_only.css new file mode 100644 index 0000000..c718cee --- /dev/null +++ b/docs/html/_static/css/badge_only.css @@ -0,0 +1 @@ +.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} \ No newline at end of file diff --git a/docs/html/_static/css/fonts/Roboto-Slab-Bold.woff b/docs/html/_static/css/fonts/Roboto-Slab-Bold.woff new file mode 100644 index 0000000..6cb6000 Binary files /dev/null and b/docs/html/_static/css/fonts/Roboto-Slab-Bold.woff differ diff --git a/docs/html/_static/css/fonts/Roboto-Slab-Bold.woff2 b/docs/html/_static/css/fonts/Roboto-Slab-Bold.woff2 new file mode 100644 index 0000000..7059e23 Binary files /dev/null and b/docs/html/_static/css/fonts/Roboto-Slab-Bold.woff2 differ diff --git a/docs/html/_static/css/fonts/Roboto-Slab-Regular.woff b/docs/html/_static/css/fonts/Roboto-Slab-Regular.woff new file mode 100644 index 0000000..f815f63 Binary files /dev/null and b/docs/html/_static/css/fonts/Roboto-Slab-Regular.woff differ diff --git a/docs/html/_static/css/fonts/Roboto-Slab-Regular.woff2 b/docs/html/_static/css/fonts/Roboto-Slab-Regular.woff2 new file mode 100644 index 0000000..f2c76e5 Binary files /dev/null and b/docs/html/_static/css/fonts/Roboto-Slab-Regular.woff2 differ diff --git a/docs/html/_static/css/fonts/fontawesome-webfont.eot b/docs/html/_static/css/fonts/fontawesome-webfont.eot new file mode 100644 index 0000000..e9f60ca Binary files /dev/null and b/docs/html/_static/css/fonts/fontawesome-webfont.eot differ diff --git a/docs/html/_static/css/fonts/fontawesome-webfont.svg b/docs/html/_static/css/fonts/fontawesome-webfont.svg new file mode 100644 index 0000000..855c845 --- /dev/null +++ b/docs/html/_static/css/fonts/fontawesome-webfont.svg @@ -0,0 +1,2671 @@ + + + + +Created by FontForge 20120731 at Mon Oct 24 17:37:40 2016 + By ,,, +Copyright Dave Gandy 2016. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/html/_static/css/fonts/fontawesome-webfont.ttf b/docs/html/_static/css/fonts/fontawesome-webfont.ttf new file mode 100644 index 0000000..35acda2 Binary files /dev/null and b/docs/html/_static/css/fonts/fontawesome-webfont.ttf differ diff --git a/docs/html/_static/css/fonts/fontawesome-webfont.woff b/docs/html/_static/css/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..400014a Binary files /dev/null and b/docs/html/_static/css/fonts/fontawesome-webfont.woff differ diff --git a/docs/html/_static/css/fonts/fontawesome-webfont.woff2 b/docs/html/_static/css/fonts/fontawesome-webfont.woff2 new file mode 100644 index 0000000..4d13fc6 Binary files /dev/null and b/docs/html/_static/css/fonts/fontawesome-webfont.woff2 differ diff --git a/docs/html/_static/css/fonts/lato-bold-italic.woff b/docs/html/_static/css/fonts/lato-bold-italic.woff new file mode 100644 index 0000000..88ad05b Binary files /dev/null and b/docs/html/_static/css/fonts/lato-bold-italic.woff differ diff --git a/docs/html/_static/css/fonts/lato-bold-italic.woff2 b/docs/html/_static/css/fonts/lato-bold-italic.woff2 new file mode 100644 index 0000000..c4e3d80 Binary files /dev/null and b/docs/html/_static/css/fonts/lato-bold-italic.woff2 differ diff --git a/docs/html/_static/css/fonts/lato-bold.woff b/docs/html/_static/css/fonts/lato-bold.woff new file mode 100644 index 0000000..c6dff51 Binary files /dev/null and b/docs/html/_static/css/fonts/lato-bold.woff differ diff --git a/docs/html/_static/css/fonts/lato-bold.woff2 b/docs/html/_static/css/fonts/lato-bold.woff2 new file mode 100644 index 0000000..bb19504 Binary files /dev/null and b/docs/html/_static/css/fonts/lato-bold.woff2 differ diff --git a/docs/html/_static/css/fonts/lato-normal-italic.woff b/docs/html/_static/css/fonts/lato-normal-italic.woff new file mode 100644 index 0000000..76114bc Binary files /dev/null and b/docs/html/_static/css/fonts/lato-normal-italic.woff differ diff --git a/docs/html/_static/css/fonts/lato-normal-italic.woff2 b/docs/html/_static/css/fonts/lato-normal-italic.woff2 new file mode 100644 index 0000000..3404f37 Binary files /dev/null and b/docs/html/_static/css/fonts/lato-normal-italic.woff2 differ diff --git a/docs/html/_static/css/fonts/lato-normal.woff b/docs/html/_static/css/fonts/lato-normal.woff new file mode 100644 index 0000000..ae1307f Binary files /dev/null and b/docs/html/_static/css/fonts/lato-normal.woff differ diff --git a/docs/html/_static/css/fonts/lato-normal.woff2 b/docs/html/_static/css/fonts/lato-normal.woff2 new file mode 100644 index 0000000..3bf9843 Binary files /dev/null and b/docs/html/_static/css/fonts/lato-normal.woff2 differ diff --git a/docs/html/_static/css/theme.css b/docs/html/_static/css/theme.css new file mode 100644 index 0000000..c03c88f --- /dev/null +++ b/docs/html/_static/css/theme.css @@ -0,0 +1,4 @@ +html{box-sizing:border-box}*,:after,:before{box-sizing:inherit}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden],audio:not([controls]){display:none}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}blockquote{margin:0}dfn{font-style:italic}ins{background:#ff9;text-decoration:none}ins,mark{color:#000}mark{background:#ff0;font-style:italic;font-weight:700}.rst-content code,.rst-content tt,code,kbd,pre,samp{font-family:monospace,serif;_font-family:courier new,monospace;font-size:1em}pre{white-space:pre}q{quotes:none}q:after,q:before{content:"";content:none}small{font-size:85%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}dl,ol,ul{margin:0;padding:0;list-style:none;list-style-image:none}li{list-style:none}dd{margin:0}img{border:0;-ms-interpolation-mode:bicubic;vertical-align:middle;max-width:100%}svg:not(:root){overflow:hidden}figure,form{margin:0}label{cursor:pointer}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal}button,input[type=button],input[type=reset],input[type=submit]{cursor:pointer;-webkit-appearance:button;*overflow:visible}button[disabled],input[disabled]{cursor:default}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}textarea{resize:vertical}table{border-collapse:collapse;border-spacing:0}td{vertical-align:top}.chromeframe{margin:.2em 0;background:#ccc;color:#000;padding:.2em 0}.ir{display:block;border:0;text-indent:-999em;overflow:hidden;background-color:transparent;background-repeat:no-repeat;text-align:left;direction:ltr;*line-height:0}.ir br{display:none}.hidden{display:none!important;visibility:hidden}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.invisible{visibility:hidden}.relative{position:relative}big,small{font-size:100%}@media print{body,html,section{background:none!important}*{box-shadow:none!important;text-shadow:none!important;filter:none!important;-ms-filter:none!important}a,a:visited{text-decoration:underline}.ir a:after,a[href^="#"]:after,a[href^="javascript:"]:after{content:""}blockquote,pre{page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}.rst-content .toctree-wrapper>p.caption,h2,h3,p{orphans:3;widows:3}.rst-content .toctree-wrapper>p.caption,h2,h3{page-break-after:avoid}}.btn,.fa:before,.icon:before,.rst-content .admonition,.rst-content .admonition-title:before,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .code-block-caption .headerlink:before,.rst-content .danger,.rst-content .eqno .headerlink:before,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning,.rst-content code.download span:first-child:before,.rst-content dl dt .headerlink:before,.rst-content h1 .headerlink:before,.rst-content h2 .headerlink:before,.rst-content h3 .headerlink:before,.rst-content h4 .headerlink:before,.rst-content h5 .headerlink:before,.rst-content h6 .headerlink:before,.rst-content p.caption .headerlink:before,.rst-content p .headerlink:before,.rst-content table>caption .headerlink:before,.rst-content tt.download span:first-child:before,.wy-alert,.wy-dropdown .caret:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a button.toctree-expand:before,.wy-menu-vertical li button.toctree-expand:before,input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week],select,textarea{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}/*! + * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome + * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) + */@font-face{font-family:FontAwesome;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713);src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix&v=4.7.0) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#fontawesomeregular) format("svg");font-weight:400;font-style:normal}.fa,.icon,.rst-content .admonition-title,.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content code.download span:first-child,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink,.rst-content tt.download span:first-child,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li button.toctree-expand{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14286em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14286em;width:2.14286em;top:.14286em;text-align:center}.fa-li.fa-lg{left:-1.85714em}.fa-border{padding:.2em .25em .15em;border:.08em solid #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa-pull-left.icon,.fa.fa-pull-left,.rst-content .code-block-caption .fa-pull-left.headerlink,.rst-content .eqno .fa-pull-left.headerlink,.rst-content .fa-pull-left.admonition-title,.rst-content code.download span.fa-pull-left:first-child,.rst-content dl dt .fa-pull-left.headerlink,.rst-content h1 .fa-pull-left.headerlink,.rst-content h2 .fa-pull-left.headerlink,.rst-content h3 .fa-pull-left.headerlink,.rst-content h4 .fa-pull-left.headerlink,.rst-content h5 .fa-pull-left.headerlink,.rst-content h6 .fa-pull-left.headerlink,.rst-content p .fa-pull-left.headerlink,.rst-content table>caption .fa-pull-left.headerlink,.rst-content tt.download span.fa-pull-left:first-child,.wy-menu-vertical li.current>a button.fa-pull-left.toctree-expand,.wy-menu-vertical li.on a button.fa-pull-left.toctree-expand,.wy-menu-vertical li button.fa-pull-left.toctree-expand{margin-right:.3em}.fa-pull-right.icon,.fa.fa-pull-right,.rst-content .code-block-caption .fa-pull-right.headerlink,.rst-content .eqno .fa-pull-right.headerlink,.rst-content .fa-pull-right.admonition-title,.rst-content code.download span.fa-pull-right:first-child,.rst-content dl dt .fa-pull-right.headerlink,.rst-content h1 .fa-pull-right.headerlink,.rst-content h2 .fa-pull-right.headerlink,.rst-content h3 .fa-pull-right.headerlink,.rst-content h4 .fa-pull-right.headerlink,.rst-content h5 .fa-pull-right.headerlink,.rst-content h6 .fa-pull-right.headerlink,.rst-content p .fa-pull-right.headerlink,.rst-content table>caption .fa-pull-right.headerlink,.rst-content tt.download span.fa-pull-right:first-child,.wy-menu-vertical li.current>a button.fa-pull-right.toctree-expand,.wy-menu-vertical li.on a button.fa-pull-right.toctree-expand,.wy-menu-vertical li button.fa-pull-right.toctree-expand{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left,.pull-left.icon,.rst-content .code-block-caption .pull-left.headerlink,.rst-content .eqno .pull-left.headerlink,.rst-content .pull-left.admonition-title,.rst-content code.download span.pull-left:first-child,.rst-content dl dt .pull-left.headerlink,.rst-content h1 .pull-left.headerlink,.rst-content h2 .pull-left.headerlink,.rst-content h3 .pull-left.headerlink,.rst-content h4 .pull-left.headerlink,.rst-content h5 .pull-left.headerlink,.rst-content h6 .pull-left.headerlink,.rst-content p .pull-left.headerlink,.rst-content table>caption .pull-left.headerlink,.rst-content tt.download span.pull-left:first-child,.wy-menu-vertical li.current>a button.pull-left.toctree-expand,.wy-menu-vertical li.on a button.pull-left.toctree-expand,.wy-menu-vertical li button.pull-left.toctree-expand{margin-right:.3em}.fa.pull-right,.pull-right.icon,.rst-content .code-block-caption .pull-right.headerlink,.rst-content .eqno .pull-right.headerlink,.rst-content .pull-right.admonition-title,.rst-content code.download span.pull-right:first-child,.rst-content dl dt .pull-right.headerlink,.rst-content h1 .pull-right.headerlink,.rst-content h2 .pull-right.headerlink,.rst-content h3 .pull-right.headerlink,.rst-content h4 .pull-right.headerlink,.rst-content h5 .pull-right.headerlink,.rst-content h6 .pull-right.headerlink,.rst-content p .pull-right.headerlink,.rst-content table>caption .pull-right.headerlink,.rst-content tt.download span.pull-right:first-child,.wy-menu-vertical li.current>a button.pull-right.toctree-expand,.wy-menu-vertical li.on a button.pull-right.toctree-expand,.wy-menu-vertical li button.pull-right.toctree-expand{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s linear infinite;animation:fa-spin 2s linear infinite}.fa-pulse{-webkit-animation:fa-spin 1s steps(8) infinite;animation:fa-spin 1s steps(8) infinite}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scaleX(-1);-ms-transform:scaleX(-1);transform:scaleX(-1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scaleY(-1);-ms-transform:scaleY(-1);transform:scaleY(-1)}:root .fa-flip-horizontal,:root .fa-flip-vertical,:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:""}.fa-music:before{content:""}.fa-search:before,.icon-search:before{content:""}.fa-envelope-o:before{content:""}.fa-heart:before{content:""}.fa-star:before{content:""}.fa-star-o:before{content:""}.fa-user:before{content:""}.fa-film:before{content:""}.fa-th-large:before{content:""}.fa-th:before{content:""}.fa-th-list:before{content:""}.fa-check:before{content:""}.fa-close:before,.fa-remove:before,.fa-times:before{content:""}.fa-search-plus:before{content:""}.fa-search-minus:before{content:""}.fa-power-off:before{content:""}.fa-signal:before{content:""}.fa-cog:before,.fa-gear:before{content:""}.fa-trash-o:before{content:""}.fa-home:before,.icon-home:before{content:""}.fa-file-o:before{content:""}.fa-clock-o:before{content:""}.fa-road:before{content:""}.fa-download:before,.rst-content code.download span:first-child:before,.rst-content tt.download span:first-child:before{content:""}.fa-arrow-circle-o-down:before{content:""}.fa-arrow-circle-o-up:before{content:""}.fa-inbox:before{content:""}.fa-play-circle-o:before{content:""}.fa-repeat:before,.fa-rotate-right:before{content:""}.fa-refresh:before{content:""}.fa-list-alt:before{content:""}.fa-lock:before{content:""}.fa-flag:before{content:""}.fa-headphones:before{content:""}.fa-volume-off:before{content:""}.fa-volume-down:before{content:""}.fa-volume-up:before{content:""}.fa-qrcode:before{content:""}.fa-barcode:before{content:""}.fa-tag:before{content:""}.fa-tags:before{content:""}.fa-book:before,.icon-book:before{content:""}.fa-bookmark:before{content:""}.fa-print:before{content:""}.fa-camera:before{content:""}.fa-font:before{content:""}.fa-bold:before{content:""}.fa-italic:before{content:""}.fa-text-height:before{content:""}.fa-text-width:before{content:""}.fa-align-left:before{content:""}.fa-align-center:before{content:""}.fa-align-right:before{content:""}.fa-align-justify:before{content:""}.fa-list:before{content:""}.fa-dedent:before,.fa-outdent:before{content:""}.fa-indent:before{content:""}.fa-video-camera:before{content:""}.fa-image:before,.fa-photo:before,.fa-picture-o:before{content:""}.fa-pencil:before{content:""}.fa-map-marker:before{content:""}.fa-adjust:before{content:""}.fa-tint:before{content:""}.fa-edit:before,.fa-pencil-square-o:before{content:""}.fa-share-square-o:before{content:""}.fa-check-square-o:before{content:""}.fa-arrows:before{content:""}.fa-step-backward:before{content:""}.fa-fast-backward:before{content:""}.fa-backward:before{content:""}.fa-play:before{content:""}.fa-pause:before{content:""}.fa-stop:before{content:""}.fa-forward:before{content:""}.fa-fast-forward:before{content:""}.fa-step-forward:before{content:""}.fa-eject:before{content:""}.fa-chevron-left:before{content:""}.fa-chevron-right:before{content:""}.fa-plus-circle:before{content:""}.fa-minus-circle:before{content:""}.fa-times-circle:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before{content:""}.fa-check-circle:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before{content:""}.fa-question-circle:before{content:""}.fa-info-circle:before{content:""}.fa-crosshairs:before{content:""}.fa-times-circle-o:before{content:""}.fa-check-circle-o:before{content:""}.fa-ban:before{content:""}.fa-arrow-left:before{content:""}.fa-arrow-right:before{content:""}.fa-arrow-up:before{content:""}.fa-arrow-down:before{content:""}.fa-mail-forward:before,.fa-share:before{content:""}.fa-expand:before{content:""}.fa-compress:before{content:""}.fa-plus:before{content:""}.fa-minus:before{content:""}.fa-asterisk:before{content:""}.fa-exclamation-circle:before,.rst-content .admonition-title:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before{content:""}.fa-gift:before{content:""}.fa-leaf:before{content:""}.fa-fire:before,.icon-fire:before{content:""}.fa-eye:before{content:""}.fa-eye-slash:before{content:""}.fa-exclamation-triangle:before,.fa-warning:before{content:""}.fa-plane:before{content:""}.fa-calendar:before{content:""}.fa-random:before{content:""}.fa-comment:before{content:""}.fa-magnet:before{content:""}.fa-chevron-up:before{content:""}.fa-chevron-down:before{content:""}.fa-retweet:before{content:""}.fa-shopping-cart:before{content:""}.fa-folder:before{content:""}.fa-folder-open:before{content:""}.fa-arrows-v:before{content:""}.fa-arrows-h:before{content:""}.fa-bar-chart-o:before,.fa-bar-chart:before{content:""}.fa-twitter-square:before{content:""}.fa-facebook-square:before{content:""}.fa-camera-retro:before{content:""}.fa-key:before{content:""}.fa-cogs:before,.fa-gears:before{content:""}.fa-comments:before{content:""}.fa-thumbs-o-up:before{content:""}.fa-thumbs-o-down:before{content:""}.fa-star-half:before{content:""}.fa-heart-o:before{content:""}.fa-sign-out:before{content:""}.fa-linkedin-square:before{content:""}.fa-thumb-tack:before{content:""}.fa-external-link:before{content:""}.fa-sign-in:before{content:""}.fa-trophy:before{content:""}.fa-github-square:before{content:""}.fa-upload:before{content:""}.fa-lemon-o:before{content:""}.fa-phone:before{content:""}.fa-square-o:before{content:""}.fa-bookmark-o:before{content:""}.fa-phone-square:before{content:""}.fa-twitter:before{content:""}.fa-facebook-f:before,.fa-facebook:before{content:""}.fa-github:before,.icon-github:before{content:""}.fa-unlock:before{content:""}.fa-credit-card:before{content:""}.fa-feed:before,.fa-rss:before{content:""}.fa-hdd-o:before{content:""}.fa-bullhorn:before{content:""}.fa-bell:before{content:""}.fa-certificate:before{content:""}.fa-hand-o-right:before{content:""}.fa-hand-o-left:before{content:""}.fa-hand-o-up:before{content:""}.fa-hand-o-down:before{content:""}.fa-arrow-circle-left:before,.icon-circle-arrow-left:before{content:""}.fa-arrow-circle-right:before,.icon-circle-arrow-right:before{content:""}.fa-arrow-circle-up:before{content:""}.fa-arrow-circle-down:before{content:""}.fa-globe:before{content:""}.fa-wrench:before{content:""}.fa-tasks:before{content:""}.fa-filter:before{content:""}.fa-briefcase:before{content:""}.fa-arrows-alt:before{content:""}.fa-group:before,.fa-users:before{content:""}.fa-chain:before,.fa-link:before,.icon-link:before{content:""}.fa-cloud:before{content:""}.fa-flask:before{content:""}.fa-cut:before,.fa-scissors:before{content:""}.fa-copy:before,.fa-files-o:before{content:""}.fa-paperclip:before{content:""}.fa-floppy-o:before,.fa-save:before{content:""}.fa-square:before{content:""}.fa-bars:before,.fa-navicon:before,.fa-reorder:before{content:""}.fa-list-ul:before{content:""}.fa-list-ol:before{content:""}.fa-strikethrough:before{content:""}.fa-underline:before{content:""}.fa-table:before{content:""}.fa-magic:before{content:""}.fa-truck:before{content:""}.fa-pinterest:before{content:""}.fa-pinterest-square:before{content:""}.fa-google-plus-square:before{content:""}.fa-google-plus:before{content:""}.fa-money:before{content:""}.fa-caret-down:before,.icon-caret-down:before,.wy-dropdown .caret:before{content:""}.fa-caret-up:before{content:""}.fa-caret-left:before{content:""}.fa-caret-right:before{content:""}.fa-columns:before{content:""}.fa-sort:before,.fa-unsorted:before{content:""}.fa-sort-desc:before,.fa-sort-down:before{content:""}.fa-sort-asc:before,.fa-sort-up:before{content:""}.fa-envelope:before{content:""}.fa-linkedin:before{content:""}.fa-rotate-left:before,.fa-undo:before{content:""}.fa-gavel:before,.fa-legal:before{content:""}.fa-dashboard:before,.fa-tachometer:before{content:""}.fa-comment-o:before{content:""}.fa-comments-o:before{content:""}.fa-bolt:before,.fa-flash:before{content:""}.fa-sitemap:before{content:""}.fa-umbrella:before{content:""}.fa-clipboard:before,.fa-paste:before{content:""}.fa-lightbulb-o:before{content:""}.fa-exchange:before{content:""}.fa-cloud-download:before{content:""}.fa-cloud-upload:before{content:""}.fa-user-md:before{content:""}.fa-stethoscope:before{content:""}.fa-suitcase:before{content:""}.fa-bell-o:before{content:""}.fa-coffee:before{content:""}.fa-cutlery:before{content:""}.fa-file-text-o:before{content:""}.fa-building-o:before{content:""}.fa-hospital-o:before{content:""}.fa-ambulance:before{content:""}.fa-medkit:before{content:""}.fa-fighter-jet:before{content:""}.fa-beer:before{content:""}.fa-h-square:before{content:""}.fa-plus-square:before{content:""}.fa-angle-double-left:before{content:""}.fa-angle-double-right:before{content:""}.fa-angle-double-up:before{content:""}.fa-angle-double-down:before{content:""}.fa-angle-left:before{content:""}.fa-angle-right:before{content:""}.fa-angle-up:before{content:""}.fa-angle-down:before{content:""}.fa-desktop:before{content:""}.fa-laptop:before{content:""}.fa-tablet:before{content:""}.fa-mobile-phone:before,.fa-mobile:before{content:""}.fa-circle-o:before{content:""}.fa-quote-left:before{content:""}.fa-quote-right:before{content:""}.fa-spinner:before{content:""}.fa-circle:before{content:""}.fa-mail-reply:before,.fa-reply:before{content:""}.fa-github-alt:before{content:""}.fa-folder-o:before{content:""}.fa-folder-open-o:before{content:""}.fa-smile-o:before{content:""}.fa-frown-o:before{content:""}.fa-meh-o:before{content:""}.fa-gamepad:before{content:""}.fa-keyboard-o:before{content:""}.fa-flag-o:before{content:""}.fa-flag-checkered:before{content:""}.fa-terminal:before{content:""}.fa-code:before{content:""}.fa-mail-reply-all:before,.fa-reply-all:before{content:""}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:""}.fa-location-arrow:before{content:""}.fa-crop:before{content:""}.fa-code-fork:before{content:""}.fa-chain-broken:before,.fa-unlink:before{content:""}.fa-question:before{content:""}.fa-info:before{content:""}.fa-exclamation:before{content:""}.fa-superscript:before{content:""}.fa-subscript:before{content:""}.fa-eraser:before{content:""}.fa-puzzle-piece:before{content:""}.fa-microphone:before{content:""}.fa-microphone-slash:before{content:""}.fa-shield:before{content:""}.fa-calendar-o:before{content:""}.fa-fire-extinguisher:before{content:""}.fa-rocket:before{content:""}.fa-maxcdn:before{content:""}.fa-chevron-circle-left:before{content:""}.fa-chevron-circle-right:before{content:""}.fa-chevron-circle-up:before{content:""}.fa-chevron-circle-down:before{content:""}.fa-html5:before{content:""}.fa-css3:before{content:""}.fa-anchor:before{content:""}.fa-unlock-alt:before{content:""}.fa-bullseye:before{content:""}.fa-ellipsis-h:before{content:""}.fa-ellipsis-v:before{content:""}.fa-rss-square:before{content:""}.fa-play-circle:before{content:""}.fa-ticket:before{content:""}.fa-minus-square:before{content:""}.fa-minus-square-o:before,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a button.toctree-expand:before{content:""}.fa-level-up:before{content:""}.fa-level-down:before{content:""}.fa-check-square:before{content:""}.fa-pencil-square:before{content:""}.fa-external-link-square:before{content:""}.fa-share-square:before{content:""}.fa-compass:before{content:""}.fa-caret-square-o-down:before,.fa-toggle-down:before{content:""}.fa-caret-square-o-up:before,.fa-toggle-up:before{content:""}.fa-caret-square-o-right:before,.fa-toggle-right:before{content:""}.fa-eur:before,.fa-euro:before{content:""}.fa-gbp:before{content:""}.fa-dollar:before,.fa-usd:before{content:""}.fa-inr:before,.fa-rupee:before{content:""}.fa-cny:before,.fa-jpy:before,.fa-rmb:before,.fa-yen:before{content:""}.fa-rouble:before,.fa-rub:before,.fa-ruble:before{content:""}.fa-krw:before,.fa-won:before{content:""}.fa-bitcoin:before,.fa-btc:before{content:""}.fa-file:before{content:""}.fa-file-text:before{content:""}.fa-sort-alpha-asc:before{content:""}.fa-sort-alpha-desc:before{content:""}.fa-sort-amount-asc:before{content:""}.fa-sort-amount-desc:before{content:""}.fa-sort-numeric-asc:before{content:""}.fa-sort-numeric-desc:before{content:""}.fa-thumbs-up:before{content:""}.fa-thumbs-down:before{content:""}.fa-youtube-square:before{content:""}.fa-youtube:before{content:""}.fa-xing:before{content:""}.fa-xing-square:before{content:""}.fa-youtube-play:before{content:""}.fa-dropbox:before{content:""}.fa-stack-overflow:before{content:""}.fa-instagram:before{content:""}.fa-flickr:before{content:""}.fa-adn:before{content:""}.fa-bitbucket:before,.icon-bitbucket:before{content:""}.fa-bitbucket-square:before{content:""}.fa-tumblr:before{content:""}.fa-tumblr-square:before{content:""}.fa-long-arrow-down:before{content:""}.fa-long-arrow-up:before{content:""}.fa-long-arrow-left:before{content:""}.fa-long-arrow-right:before{content:""}.fa-apple:before{content:""}.fa-windows:before{content:""}.fa-android:before{content:""}.fa-linux:before{content:""}.fa-dribbble:before{content:""}.fa-skype:before{content:""}.fa-foursquare:before{content:""}.fa-trello:before{content:""}.fa-female:before{content:""}.fa-male:before{content:""}.fa-gittip:before,.fa-gratipay:before{content:""}.fa-sun-o:before{content:""}.fa-moon-o:before{content:""}.fa-archive:before{content:""}.fa-bug:before{content:""}.fa-vk:before{content:""}.fa-weibo:before{content:""}.fa-renren:before{content:""}.fa-pagelines:before{content:""}.fa-stack-exchange:before{content:""}.fa-arrow-circle-o-right:before{content:""}.fa-arrow-circle-o-left:before{content:""}.fa-caret-square-o-left:before,.fa-toggle-left:before{content:""}.fa-dot-circle-o:before{content:""}.fa-wheelchair:before{content:""}.fa-vimeo-square:before{content:""}.fa-try:before,.fa-turkish-lira:before{content:""}.fa-plus-square-o:before,.wy-menu-vertical li button.toctree-expand:before{content:""}.fa-space-shuttle:before{content:""}.fa-slack:before{content:""}.fa-envelope-square:before{content:""}.fa-wordpress:before{content:""}.fa-openid:before{content:""}.fa-bank:before,.fa-institution:before,.fa-university:before{content:""}.fa-graduation-cap:before,.fa-mortar-board:before{content:""}.fa-yahoo:before{content:""}.fa-google:before{content:""}.fa-reddit:before{content:""}.fa-reddit-square:before{content:""}.fa-stumbleupon-circle:before{content:""}.fa-stumbleupon:before{content:""}.fa-delicious:before{content:""}.fa-digg:before{content:""}.fa-pied-piper-pp:before{content:""}.fa-pied-piper-alt:before{content:""}.fa-drupal:before{content:""}.fa-joomla:before{content:""}.fa-language:before{content:""}.fa-fax:before{content:""}.fa-building:before{content:""}.fa-child:before{content:""}.fa-paw:before{content:""}.fa-spoon:before{content:""}.fa-cube:before{content:""}.fa-cubes:before{content:""}.fa-behance:before{content:""}.fa-behance-square:before{content:""}.fa-steam:before{content:""}.fa-steam-square:before{content:""}.fa-recycle:before{content:""}.fa-automobile:before,.fa-car:before{content:""}.fa-cab:before,.fa-taxi:before{content:""}.fa-tree:before{content:""}.fa-spotify:before{content:""}.fa-deviantart:before{content:""}.fa-soundcloud:before{content:""}.fa-database:before{content:""}.fa-file-pdf-o:before{content:""}.fa-file-word-o:before{content:""}.fa-file-excel-o:before{content:""}.fa-file-powerpoint-o:before{content:""}.fa-file-image-o:before,.fa-file-photo-o:before,.fa-file-picture-o:before{content:""}.fa-file-archive-o:before,.fa-file-zip-o:before{content:""}.fa-file-audio-o:before,.fa-file-sound-o:before{content:""}.fa-file-movie-o:before,.fa-file-video-o:before{content:""}.fa-file-code-o:before{content:""}.fa-vine:before{content:""}.fa-codepen:before{content:""}.fa-jsfiddle:before{content:""}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-ring:before,.fa-life-saver:before,.fa-support:before{content:""}.fa-circle-o-notch:before{content:""}.fa-ra:before,.fa-rebel:before,.fa-resistance:before{content:""}.fa-empire:before,.fa-ge:before{content:""}.fa-git-square:before{content:""}.fa-git:before{content:""}.fa-hacker-news:before,.fa-y-combinator-square:before,.fa-yc-square:before{content:""}.fa-tencent-weibo:before{content:""}.fa-qq:before{content:""}.fa-wechat:before,.fa-weixin:before{content:""}.fa-paper-plane:before,.fa-send:before{content:""}.fa-paper-plane-o:before,.fa-send-o:before{content:""}.fa-history:before{content:""}.fa-circle-thin:before{content:""}.fa-header:before{content:""}.fa-paragraph:before{content:""}.fa-sliders:before{content:""}.fa-share-alt:before{content:""}.fa-share-alt-square:before{content:""}.fa-bomb:before{content:""}.fa-futbol-o:before,.fa-soccer-ball-o:before{content:""}.fa-tty:before{content:""}.fa-binoculars:before{content:""}.fa-plug:before{content:""}.fa-slideshare:before{content:""}.fa-twitch:before{content:""}.fa-yelp:before{content:""}.fa-newspaper-o:before{content:""}.fa-wifi:before{content:""}.fa-calculator:before{content:""}.fa-paypal:before{content:""}.fa-google-wallet:before{content:""}.fa-cc-visa:before{content:""}.fa-cc-mastercard:before{content:""}.fa-cc-discover:before{content:""}.fa-cc-amex:before{content:""}.fa-cc-paypal:before{content:""}.fa-cc-stripe:before{content:""}.fa-bell-slash:before{content:""}.fa-bell-slash-o:before{content:""}.fa-trash:before{content:""}.fa-copyright:before{content:""}.fa-at:before{content:""}.fa-eyedropper:before{content:""}.fa-paint-brush:before{content:""}.fa-birthday-cake:before{content:""}.fa-area-chart:before{content:""}.fa-pie-chart:before{content:""}.fa-line-chart:before{content:""}.fa-lastfm:before{content:""}.fa-lastfm-square:before{content:""}.fa-toggle-off:before{content:""}.fa-toggle-on:before{content:""}.fa-bicycle:before{content:""}.fa-bus:before{content:""}.fa-ioxhost:before{content:""}.fa-angellist:before{content:""}.fa-cc:before{content:""}.fa-ils:before,.fa-shekel:before,.fa-sheqel:before{content:""}.fa-meanpath:before{content:""}.fa-buysellads:before{content:""}.fa-connectdevelop:before{content:""}.fa-dashcube:before{content:""}.fa-forumbee:before{content:""}.fa-leanpub:before{content:""}.fa-sellsy:before{content:""}.fa-shirtsinbulk:before{content:""}.fa-simplybuilt:before{content:""}.fa-skyatlas:before{content:""}.fa-cart-plus:before{content:""}.fa-cart-arrow-down:before{content:""}.fa-diamond:before{content:""}.fa-ship:before{content:""}.fa-user-secret:before{content:""}.fa-motorcycle:before{content:""}.fa-street-view:before{content:""}.fa-heartbeat:before{content:""}.fa-venus:before{content:""}.fa-mars:before{content:""}.fa-mercury:before{content:""}.fa-intersex:before,.fa-transgender:before{content:""}.fa-transgender-alt:before{content:""}.fa-venus-double:before{content:""}.fa-mars-double:before{content:""}.fa-venus-mars:before{content:""}.fa-mars-stroke:before{content:""}.fa-mars-stroke-v:before{content:""}.fa-mars-stroke-h:before{content:""}.fa-neuter:before{content:""}.fa-genderless:before{content:""}.fa-facebook-official:before{content:""}.fa-pinterest-p:before{content:""}.fa-whatsapp:before{content:""}.fa-server:before{content:""}.fa-user-plus:before{content:""}.fa-user-times:before{content:""}.fa-bed:before,.fa-hotel:before{content:""}.fa-viacoin:before{content:""}.fa-train:before{content:""}.fa-subway:before{content:""}.fa-medium:before{content:""}.fa-y-combinator:before,.fa-yc:before{content:""}.fa-optin-monster:before{content:""}.fa-opencart:before{content:""}.fa-expeditedssl:before{content:""}.fa-battery-4:before,.fa-battery-full:before,.fa-battery:before{content:""}.fa-battery-3:before,.fa-battery-three-quarters:before{content:""}.fa-battery-2:before,.fa-battery-half:before{content:""}.fa-battery-1:before,.fa-battery-quarter:before{content:""}.fa-battery-0:before,.fa-battery-empty:before{content:""}.fa-mouse-pointer:before{content:""}.fa-i-cursor:before{content:""}.fa-object-group:before{content:""}.fa-object-ungroup:before{content:""}.fa-sticky-note:before{content:""}.fa-sticky-note-o:before{content:""}.fa-cc-jcb:before{content:""}.fa-cc-diners-club:before{content:""}.fa-clone:before{content:""}.fa-balance-scale:before{content:""}.fa-hourglass-o:before{content:""}.fa-hourglass-1:before,.fa-hourglass-start:before{content:""}.fa-hourglass-2:before,.fa-hourglass-half:before{content:""}.fa-hourglass-3:before,.fa-hourglass-end:before{content:""}.fa-hourglass:before{content:""}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:""}.fa-hand-paper-o:before,.fa-hand-stop-o:before{content:""}.fa-hand-scissors-o:before{content:""}.fa-hand-lizard-o:before{content:""}.fa-hand-spock-o:before{content:""}.fa-hand-pointer-o:before{content:""}.fa-hand-peace-o:before{content:""}.fa-trademark:before{content:""}.fa-registered:before{content:""}.fa-creative-commons:before{content:""}.fa-gg:before{content:""}.fa-gg-circle:before{content:""}.fa-tripadvisor:before{content:""}.fa-odnoklassniki:before{content:""}.fa-odnoklassniki-square:before{content:""}.fa-get-pocket:before{content:""}.fa-wikipedia-w:before{content:""}.fa-safari:before{content:""}.fa-chrome:before{content:""}.fa-firefox:before{content:""}.fa-opera:before{content:""}.fa-internet-explorer:before{content:""}.fa-television:before,.fa-tv:before{content:""}.fa-contao:before{content:""}.fa-500px:before{content:""}.fa-amazon:before{content:""}.fa-calendar-plus-o:before{content:""}.fa-calendar-minus-o:before{content:""}.fa-calendar-times-o:before{content:""}.fa-calendar-check-o:before{content:""}.fa-industry:before{content:""}.fa-map-pin:before{content:""}.fa-map-signs:before{content:""}.fa-map-o:before{content:""}.fa-map:before{content:""}.fa-commenting:before{content:""}.fa-commenting-o:before{content:""}.fa-houzz:before{content:""}.fa-vimeo:before{content:""}.fa-black-tie:before{content:""}.fa-fonticons:before{content:""}.fa-reddit-alien:before{content:""}.fa-edge:before{content:""}.fa-credit-card-alt:before{content:""}.fa-codiepie:before{content:""}.fa-modx:before{content:""}.fa-fort-awesome:before{content:""}.fa-usb:before{content:""}.fa-product-hunt:before{content:""}.fa-mixcloud:before{content:""}.fa-scribd:before{content:""}.fa-pause-circle:before{content:""}.fa-pause-circle-o:before{content:""}.fa-stop-circle:before{content:""}.fa-stop-circle-o:before{content:""}.fa-shopping-bag:before{content:""}.fa-shopping-basket:before{content:""}.fa-hashtag:before{content:""}.fa-bluetooth:before{content:""}.fa-bluetooth-b:before{content:""}.fa-percent:before{content:""}.fa-gitlab:before,.icon-gitlab:before{content:""}.fa-wpbeginner:before{content:""}.fa-wpforms:before{content:""}.fa-envira:before{content:""}.fa-universal-access:before{content:""}.fa-wheelchair-alt:before{content:""}.fa-question-circle-o:before{content:""}.fa-blind:before{content:""}.fa-audio-description:before{content:""}.fa-volume-control-phone:before{content:""}.fa-braille:before{content:""}.fa-assistive-listening-systems:before{content:""}.fa-american-sign-language-interpreting:before,.fa-asl-interpreting:before{content:""}.fa-deaf:before,.fa-deafness:before,.fa-hard-of-hearing:before{content:""}.fa-glide:before{content:""}.fa-glide-g:before{content:""}.fa-sign-language:before,.fa-signing:before{content:""}.fa-low-vision:before{content:""}.fa-viadeo:before{content:""}.fa-viadeo-square:before{content:""}.fa-snapchat:before{content:""}.fa-snapchat-ghost:before{content:""}.fa-snapchat-square:before{content:""}.fa-pied-piper:before{content:""}.fa-first-order:before{content:""}.fa-yoast:before{content:""}.fa-themeisle:before{content:""}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:""}.fa-fa:before,.fa-font-awesome:before{content:""}.fa-handshake-o:before{content:""}.fa-envelope-open:before{content:""}.fa-envelope-open-o:before{content:""}.fa-linode:before{content:""}.fa-address-book:before{content:""}.fa-address-book-o:before{content:""}.fa-address-card:before,.fa-vcard:before{content:""}.fa-address-card-o:before,.fa-vcard-o:before{content:""}.fa-user-circle:before{content:""}.fa-user-circle-o:before{content:""}.fa-user-o:before{content:""}.fa-id-badge:before{content:""}.fa-drivers-license:before,.fa-id-card:before{content:""}.fa-drivers-license-o:before,.fa-id-card-o:before{content:""}.fa-quora:before{content:""}.fa-free-code-camp:before{content:""}.fa-telegram:before{content:""}.fa-thermometer-4:before,.fa-thermometer-full:before,.fa-thermometer:before{content:""}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:""}.fa-thermometer-2:before,.fa-thermometer-half:before{content:""}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:""}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:""}.fa-shower:before{content:""}.fa-bath:before,.fa-bathtub:before,.fa-s15:before{content:""}.fa-podcast:before{content:""}.fa-window-maximize:before{content:""}.fa-window-minimize:before{content:""}.fa-window-restore:before{content:""}.fa-times-rectangle:before,.fa-window-close:before{content:""}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:""}.fa-bandcamp:before{content:""}.fa-grav:before{content:""}.fa-etsy:before{content:""}.fa-imdb:before{content:""}.fa-ravelry:before{content:""}.fa-eercast:before{content:""}.fa-microchip:before{content:""}.fa-snowflake-o:before{content:""}.fa-superpowers:before{content:""}.fa-wpexplorer:before{content:""}.fa-meetup:before{content:""}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.fa,.icon,.rst-content .admonition-title,.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content code.download span:first-child,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink,.rst-content tt.download span:first-child,.wy-dropdown .caret,.wy-inline-validate.wy-inline-validate-danger .wy-input-context,.wy-inline-validate.wy-inline-validate-info .wy-input-context,.wy-inline-validate.wy-inline-validate-success .wy-input-context,.wy-inline-validate.wy-inline-validate-warning .wy-input-context,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li button.toctree-expand{font-family:inherit}.fa:before,.icon:before,.rst-content .admonition-title:before,.rst-content .code-block-caption .headerlink:before,.rst-content .eqno .headerlink:before,.rst-content code.download span:first-child:before,.rst-content dl dt .headerlink:before,.rst-content h1 .headerlink:before,.rst-content h2 .headerlink:before,.rst-content h3 .headerlink:before,.rst-content h4 .headerlink:before,.rst-content h5 .headerlink:before,.rst-content h6 .headerlink:before,.rst-content p.caption .headerlink:before,.rst-content p .headerlink:before,.rst-content table>caption .headerlink:before,.rst-content tt.download span:first-child:before,.wy-dropdown .caret:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a button.toctree-expand:before,.wy-menu-vertical li button.toctree-expand:before{font-family:FontAwesome;display:inline-block;font-style:normal;font-weight:400;line-height:1;text-decoration:inherit}.rst-content .code-block-caption a .headerlink,.rst-content .eqno a .headerlink,.rst-content a .admonition-title,.rst-content code.download a span:first-child,.rst-content dl dt a .headerlink,.rst-content h1 a .headerlink,.rst-content h2 a .headerlink,.rst-content h3 a .headerlink,.rst-content h4 a .headerlink,.rst-content h5 a .headerlink,.rst-content h6 a .headerlink,.rst-content p.caption a .headerlink,.rst-content p a .headerlink,.rst-content table>caption a .headerlink,.rst-content tt.download a span:first-child,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li a button.toctree-expand,a .fa,a .icon,a .rst-content .admonition-title,a .rst-content .code-block-caption .headerlink,a .rst-content .eqno .headerlink,a .rst-content code.download span:first-child,a .rst-content dl dt .headerlink,a .rst-content h1 .headerlink,a .rst-content h2 .headerlink,a .rst-content h3 .headerlink,a .rst-content h4 .headerlink,a .rst-content h5 .headerlink,a .rst-content h6 .headerlink,a .rst-content p.caption .headerlink,a .rst-content p .headerlink,a .rst-content table>caption .headerlink,a .rst-content tt.download span:first-child,a .wy-menu-vertical li button.toctree-expand{display:inline-block;text-decoration:inherit}.btn .fa,.btn .icon,.btn .rst-content .admonition-title,.btn .rst-content .code-block-caption .headerlink,.btn .rst-content .eqno .headerlink,.btn .rst-content code.download span:first-child,.btn .rst-content dl dt .headerlink,.btn .rst-content h1 .headerlink,.btn .rst-content h2 .headerlink,.btn .rst-content h3 .headerlink,.btn .rst-content h4 .headerlink,.btn .rst-content h5 .headerlink,.btn .rst-content h6 .headerlink,.btn .rst-content p .headerlink,.btn .rst-content table>caption .headerlink,.btn .rst-content tt.download span:first-child,.btn .wy-menu-vertical li.current>a button.toctree-expand,.btn .wy-menu-vertical li.on a button.toctree-expand,.btn .wy-menu-vertical li button.toctree-expand,.nav .fa,.nav .icon,.nav .rst-content .admonition-title,.nav .rst-content .code-block-caption .headerlink,.nav .rst-content .eqno .headerlink,.nav .rst-content code.download span:first-child,.nav .rst-content dl dt .headerlink,.nav .rst-content h1 .headerlink,.nav .rst-content h2 .headerlink,.nav .rst-content h3 .headerlink,.nav .rst-content h4 .headerlink,.nav .rst-content h5 .headerlink,.nav .rst-content h6 .headerlink,.nav .rst-content p .headerlink,.nav .rst-content table>caption .headerlink,.nav .rst-content tt.download span:first-child,.nav .wy-menu-vertical li.current>a button.toctree-expand,.nav .wy-menu-vertical li.on a button.toctree-expand,.nav .wy-menu-vertical li button.toctree-expand,.rst-content .btn .admonition-title,.rst-content .code-block-caption .btn .headerlink,.rst-content .code-block-caption .nav .headerlink,.rst-content .eqno .btn .headerlink,.rst-content .eqno .nav .headerlink,.rst-content .nav .admonition-title,.rst-content code.download .btn span:first-child,.rst-content code.download .nav span:first-child,.rst-content dl dt .btn .headerlink,.rst-content dl dt .nav .headerlink,.rst-content h1 .btn .headerlink,.rst-content h1 .nav .headerlink,.rst-content h2 .btn .headerlink,.rst-content h2 .nav .headerlink,.rst-content h3 .btn .headerlink,.rst-content h3 .nav .headerlink,.rst-content h4 .btn .headerlink,.rst-content h4 .nav .headerlink,.rst-content h5 .btn .headerlink,.rst-content h5 .nav .headerlink,.rst-content h6 .btn .headerlink,.rst-content h6 .nav .headerlink,.rst-content p .btn .headerlink,.rst-content p .nav .headerlink,.rst-content table>caption .btn .headerlink,.rst-content table>caption .nav .headerlink,.rst-content tt.download .btn span:first-child,.rst-content tt.download .nav span:first-child,.wy-menu-vertical li .btn button.toctree-expand,.wy-menu-vertical li.current>a .btn button.toctree-expand,.wy-menu-vertical li.current>a .nav button.toctree-expand,.wy-menu-vertical li .nav button.toctree-expand,.wy-menu-vertical li.on a .btn button.toctree-expand,.wy-menu-vertical li.on a .nav button.toctree-expand{display:inline}.btn .fa-large.icon,.btn .fa.fa-large,.btn .rst-content .code-block-caption .fa-large.headerlink,.btn .rst-content .eqno .fa-large.headerlink,.btn .rst-content .fa-large.admonition-title,.btn .rst-content code.download span.fa-large:first-child,.btn .rst-content dl dt .fa-large.headerlink,.btn .rst-content h1 .fa-large.headerlink,.btn .rst-content h2 .fa-large.headerlink,.btn .rst-content h3 .fa-large.headerlink,.btn .rst-content h4 .fa-large.headerlink,.btn .rst-content h5 .fa-large.headerlink,.btn .rst-content h6 .fa-large.headerlink,.btn .rst-content p .fa-large.headerlink,.btn .rst-content table>caption .fa-large.headerlink,.btn .rst-content tt.download span.fa-large:first-child,.btn .wy-menu-vertical li button.fa-large.toctree-expand,.nav .fa-large.icon,.nav .fa.fa-large,.nav .rst-content .code-block-caption .fa-large.headerlink,.nav .rst-content .eqno .fa-large.headerlink,.nav .rst-content .fa-large.admonition-title,.nav .rst-content code.download span.fa-large:first-child,.nav .rst-content dl dt .fa-large.headerlink,.nav .rst-content h1 .fa-large.headerlink,.nav .rst-content h2 .fa-large.headerlink,.nav .rst-content h3 .fa-large.headerlink,.nav .rst-content h4 .fa-large.headerlink,.nav .rst-content h5 .fa-large.headerlink,.nav .rst-content h6 .fa-large.headerlink,.nav .rst-content p .fa-large.headerlink,.nav .rst-content table>caption .fa-large.headerlink,.nav .rst-content tt.download span.fa-large:first-child,.nav .wy-menu-vertical li button.fa-large.toctree-expand,.rst-content .btn .fa-large.admonition-title,.rst-content .code-block-caption .btn .fa-large.headerlink,.rst-content .code-block-caption .nav .fa-large.headerlink,.rst-content .eqno .btn .fa-large.headerlink,.rst-content .eqno .nav .fa-large.headerlink,.rst-content .nav .fa-large.admonition-title,.rst-content code.download .btn span.fa-large:first-child,.rst-content code.download .nav span.fa-large:first-child,.rst-content dl dt .btn .fa-large.headerlink,.rst-content dl dt .nav .fa-large.headerlink,.rst-content h1 .btn .fa-large.headerlink,.rst-content h1 .nav .fa-large.headerlink,.rst-content h2 .btn .fa-large.headerlink,.rst-content h2 .nav .fa-large.headerlink,.rst-content h3 .btn .fa-large.headerlink,.rst-content h3 .nav .fa-large.headerlink,.rst-content h4 .btn .fa-large.headerlink,.rst-content h4 .nav .fa-large.headerlink,.rst-content h5 .btn .fa-large.headerlink,.rst-content h5 .nav .fa-large.headerlink,.rst-content h6 .btn .fa-large.headerlink,.rst-content h6 .nav .fa-large.headerlink,.rst-content p .btn .fa-large.headerlink,.rst-content p .nav .fa-large.headerlink,.rst-content table>caption .btn .fa-large.headerlink,.rst-content table>caption .nav .fa-large.headerlink,.rst-content tt.download .btn span.fa-large:first-child,.rst-content tt.download .nav span.fa-large:first-child,.wy-menu-vertical li .btn button.fa-large.toctree-expand,.wy-menu-vertical li .nav button.fa-large.toctree-expand{line-height:.9em}.btn .fa-spin.icon,.btn .fa.fa-spin,.btn .rst-content .code-block-caption .fa-spin.headerlink,.btn .rst-content .eqno .fa-spin.headerlink,.btn .rst-content .fa-spin.admonition-title,.btn .rst-content code.download span.fa-spin:first-child,.btn .rst-content dl dt .fa-spin.headerlink,.btn .rst-content h1 .fa-spin.headerlink,.btn .rst-content h2 .fa-spin.headerlink,.btn .rst-content h3 .fa-spin.headerlink,.btn .rst-content h4 .fa-spin.headerlink,.btn .rst-content h5 .fa-spin.headerlink,.btn .rst-content h6 .fa-spin.headerlink,.btn .rst-content p .fa-spin.headerlink,.btn .rst-content table>caption .fa-spin.headerlink,.btn .rst-content tt.download span.fa-spin:first-child,.btn .wy-menu-vertical li button.fa-spin.toctree-expand,.nav .fa-spin.icon,.nav .fa.fa-spin,.nav .rst-content .code-block-caption .fa-spin.headerlink,.nav .rst-content .eqno .fa-spin.headerlink,.nav .rst-content .fa-spin.admonition-title,.nav .rst-content code.download span.fa-spin:first-child,.nav .rst-content dl dt .fa-spin.headerlink,.nav .rst-content h1 .fa-spin.headerlink,.nav .rst-content h2 .fa-spin.headerlink,.nav .rst-content h3 .fa-spin.headerlink,.nav .rst-content h4 .fa-spin.headerlink,.nav .rst-content h5 .fa-spin.headerlink,.nav .rst-content h6 .fa-spin.headerlink,.nav .rst-content p .fa-spin.headerlink,.nav .rst-content table>caption .fa-spin.headerlink,.nav .rst-content tt.download span.fa-spin:first-child,.nav .wy-menu-vertical li button.fa-spin.toctree-expand,.rst-content .btn .fa-spin.admonition-title,.rst-content .code-block-caption .btn .fa-spin.headerlink,.rst-content .code-block-caption .nav .fa-spin.headerlink,.rst-content .eqno .btn .fa-spin.headerlink,.rst-content .eqno .nav .fa-spin.headerlink,.rst-content .nav .fa-spin.admonition-title,.rst-content code.download .btn span.fa-spin:first-child,.rst-content code.download .nav span.fa-spin:first-child,.rst-content dl dt .btn .fa-spin.headerlink,.rst-content dl dt .nav .fa-spin.headerlink,.rst-content h1 .btn .fa-spin.headerlink,.rst-content h1 .nav .fa-spin.headerlink,.rst-content h2 .btn .fa-spin.headerlink,.rst-content h2 .nav .fa-spin.headerlink,.rst-content h3 .btn .fa-spin.headerlink,.rst-content h3 .nav .fa-spin.headerlink,.rst-content h4 .btn .fa-spin.headerlink,.rst-content h4 .nav .fa-spin.headerlink,.rst-content h5 .btn .fa-spin.headerlink,.rst-content h5 .nav .fa-spin.headerlink,.rst-content h6 .btn .fa-spin.headerlink,.rst-content h6 .nav .fa-spin.headerlink,.rst-content p .btn .fa-spin.headerlink,.rst-content p .nav .fa-spin.headerlink,.rst-content table>caption .btn .fa-spin.headerlink,.rst-content table>caption .nav .fa-spin.headerlink,.rst-content tt.download .btn span.fa-spin:first-child,.rst-content tt.download .nav span.fa-spin:first-child,.wy-menu-vertical li .btn button.fa-spin.toctree-expand,.wy-menu-vertical li .nav button.fa-spin.toctree-expand{display:inline-block}.btn.fa:before,.btn.icon:before,.rst-content .btn.admonition-title:before,.rst-content .code-block-caption .btn.headerlink:before,.rst-content .eqno .btn.headerlink:before,.rst-content code.download span.btn:first-child:before,.rst-content dl dt .btn.headerlink:before,.rst-content h1 .btn.headerlink:before,.rst-content h2 .btn.headerlink:before,.rst-content h3 .btn.headerlink:before,.rst-content h4 .btn.headerlink:before,.rst-content h5 .btn.headerlink:before,.rst-content h6 .btn.headerlink:before,.rst-content p .btn.headerlink:before,.rst-content table>caption .btn.headerlink:before,.rst-content tt.download span.btn:first-child:before,.wy-menu-vertical li button.btn.toctree-expand:before{opacity:.5;-webkit-transition:opacity .05s ease-in;-moz-transition:opacity .05s ease-in;transition:opacity .05s ease-in}.btn.fa:hover:before,.btn.icon:hover:before,.rst-content .btn.admonition-title:hover:before,.rst-content .code-block-caption .btn.headerlink:hover:before,.rst-content .eqno .btn.headerlink:hover:before,.rst-content code.download span.btn:first-child:hover:before,.rst-content dl dt .btn.headerlink:hover:before,.rst-content h1 .btn.headerlink:hover:before,.rst-content h2 .btn.headerlink:hover:before,.rst-content h3 .btn.headerlink:hover:before,.rst-content h4 .btn.headerlink:hover:before,.rst-content h5 .btn.headerlink:hover:before,.rst-content h6 .btn.headerlink:hover:before,.rst-content p .btn.headerlink:hover:before,.rst-content table>caption .btn.headerlink:hover:before,.rst-content tt.download span.btn:first-child:hover:before,.wy-menu-vertical li button.btn.toctree-expand:hover:before{opacity:1}.btn-mini .fa:before,.btn-mini .icon:before,.btn-mini .rst-content .admonition-title:before,.btn-mini .rst-content .code-block-caption .headerlink:before,.btn-mini .rst-content .eqno .headerlink:before,.btn-mini .rst-content code.download span:first-child:before,.btn-mini .rst-content dl dt .headerlink:before,.btn-mini .rst-content h1 .headerlink:before,.btn-mini .rst-content h2 .headerlink:before,.btn-mini .rst-content h3 .headerlink:before,.btn-mini .rst-content h4 .headerlink:before,.btn-mini .rst-content h5 .headerlink:before,.btn-mini .rst-content h6 .headerlink:before,.btn-mini .rst-content p .headerlink:before,.btn-mini .rst-content table>caption .headerlink:before,.btn-mini .rst-content tt.download span:first-child:before,.btn-mini .wy-menu-vertical li button.toctree-expand:before,.rst-content .btn-mini .admonition-title:before,.rst-content .code-block-caption .btn-mini .headerlink:before,.rst-content .eqno .btn-mini .headerlink:before,.rst-content code.download .btn-mini span:first-child:before,.rst-content dl dt .btn-mini .headerlink:before,.rst-content h1 .btn-mini .headerlink:before,.rst-content h2 .btn-mini .headerlink:before,.rst-content h3 .btn-mini .headerlink:before,.rst-content h4 .btn-mini .headerlink:before,.rst-content h5 .btn-mini .headerlink:before,.rst-content h6 .btn-mini .headerlink:before,.rst-content p .btn-mini .headerlink:before,.rst-content table>caption .btn-mini .headerlink:before,.rst-content tt.download .btn-mini span:first-child:before,.wy-menu-vertical li .btn-mini button.toctree-expand:before{font-size:14px;vertical-align:-15%}.rst-content .admonition,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .danger,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning,.wy-alert{padding:12px;line-height:24px;margin-bottom:24px;background:#e7f2fa}.rst-content .admonition-title,.wy-alert-title{font-weight:700;display:block;color:#fff;background:#6ab0de;padding:6px 12px;margin:-12px -12px 12px}.rst-content .danger,.rst-content .error,.rst-content .wy-alert-danger.admonition,.rst-content .wy-alert-danger.admonition-todo,.rst-content .wy-alert-danger.attention,.rst-content .wy-alert-danger.caution,.rst-content .wy-alert-danger.hint,.rst-content .wy-alert-danger.important,.rst-content .wy-alert-danger.note,.rst-content .wy-alert-danger.seealso,.rst-content .wy-alert-danger.tip,.rst-content .wy-alert-danger.warning,.wy-alert.wy-alert-danger{background:#fdf3f2}.rst-content .danger .admonition-title,.rst-content .danger .wy-alert-title,.rst-content .error .admonition-title,.rst-content .error .wy-alert-title,.rst-content .wy-alert-danger.admonition-todo .admonition-title,.rst-content .wy-alert-danger.admonition-todo .wy-alert-title,.rst-content .wy-alert-danger.admonition .admonition-title,.rst-content .wy-alert-danger.admonition .wy-alert-title,.rst-content .wy-alert-danger.attention .admonition-title,.rst-content .wy-alert-danger.attention .wy-alert-title,.rst-content .wy-alert-danger.caution .admonition-title,.rst-content .wy-alert-danger.caution .wy-alert-title,.rst-content .wy-alert-danger.hint .admonition-title,.rst-content .wy-alert-danger.hint .wy-alert-title,.rst-content .wy-alert-danger.important .admonition-title,.rst-content .wy-alert-danger.important .wy-alert-title,.rst-content .wy-alert-danger.note .admonition-title,.rst-content .wy-alert-danger.note .wy-alert-title,.rst-content .wy-alert-danger.seealso .admonition-title,.rst-content .wy-alert-danger.seealso .wy-alert-title,.rst-content .wy-alert-danger.tip .admonition-title,.rst-content .wy-alert-danger.tip .wy-alert-title,.rst-content .wy-alert-danger.warning .admonition-title,.rst-content .wy-alert-danger.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-danger .admonition-title,.wy-alert.wy-alert-danger .rst-content .admonition-title,.wy-alert.wy-alert-danger .wy-alert-title{background:#f29f97}.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .warning,.rst-content .wy-alert-warning.admonition,.rst-content .wy-alert-warning.danger,.rst-content .wy-alert-warning.error,.rst-content .wy-alert-warning.hint,.rst-content .wy-alert-warning.important,.rst-content .wy-alert-warning.note,.rst-content .wy-alert-warning.seealso,.rst-content .wy-alert-warning.tip,.wy-alert.wy-alert-warning{background:#ffedcc}.rst-content .admonition-todo .admonition-title,.rst-content .admonition-todo .wy-alert-title,.rst-content .attention .admonition-title,.rst-content .attention .wy-alert-title,.rst-content .caution .admonition-title,.rst-content .caution .wy-alert-title,.rst-content .warning .admonition-title,.rst-content .warning .wy-alert-title,.rst-content .wy-alert-warning.admonition .admonition-title,.rst-content .wy-alert-warning.admonition .wy-alert-title,.rst-content .wy-alert-warning.danger .admonition-title,.rst-content .wy-alert-warning.danger .wy-alert-title,.rst-content .wy-alert-warning.error .admonition-title,.rst-content .wy-alert-warning.error .wy-alert-title,.rst-content .wy-alert-warning.hint .admonition-title,.rst-content .wy-alert-warning.hint .wy-alert-title,.rst-content .wy-alert-warning.important .admonition-title,.rst-content .wy-alert-warning.important .wy-alert-title,.rst-content .wy-alert-warning.note .admonition-title,.rst-content .wy-alert-warning.note .wy-alert-title,.rst-content .wy-alert-warning.seealso .admonition-title,.rst-content .wy-alert-warning.seealso .wy-alert-title,.rst-content .wy-alert-warning.tip .admonition-title,.rst-content .wy-alert-warning.tip .wy-alert-title,.rst-content .wy-alert.wy-alert-warning .admonition-title,.wy-alert.wy-alert-warning .rst-content .admonition-title,.wy-alert.wy-alert-warning .wy-alert-title{background:#f0b37e}.rst-content .note,.rst-content .seealso,.rst-content .wy-alert-info.admonition,.rst-content .wy-alert-info.admonition-todo,.rst-content .wy-alert-info.attention,.rst-content .wy-alert-info.caution,.rst-content .wy-alert-info.danger,.rst-content .wy-alert-info.error,.rst-content .wy-alert-info.hint,.rst-content .wy-alert-info.important,.rst-content .wy-alert-info.tip,.rst-content .wy-alert-info.warning,.wy-alert.wy-alert-info{background:#e7f2fa}.rst-content .note .admonition-title,.rst-content .note .wy-alert-title,.rst-content .seealso .admonition-title,.rst-content .seealso .wy-alert-title,.rst-content .wy-alert-info.admonition-todo .admonition-title,.rst-content .wy-alert-info.admonition-todo .wy-alert-title,.rst-content .wy-alert-info.admonition .admonition-title,.rst-content .wy-alert-info.admonition .wy-alert-title,.rst-content .wy-alert-info.attention .admonition-title,.rst-content .wy-alert-info.attention .wy-alert-title,.rst-content .wy-alert-info.caution .admonition-title,.rst-content .wy-alert-info.caution .wy-alert-title,.rst-content .wy-alert-info.danger .admonition-title,.rst-content .wy-alert-info.danger .wy-alert-title,.rst-content .wy-alert-info.error .admonition-title,.rst-content .wy-alert-info.error .wy-alert-title,.rst-content .wy-alert-info.hint .admonition-title,.rst-content .wy-alert-info.hint .wy-alert-title,.rst-content .wy-alert-info.important .admonition-title,.rst-content .wy-alert-info.important .wy-alert-title,.rst-content .wy-alert-info.tip .admonition-title,.rst-content .wy-alert-info.tip .wy-alert-title,.rst-content .wy-alert-info.warning .admonition-title,.rst-content .wy-alert-info.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-info .admonition-title,.wy-alert.wy-alert-info .rst-content .admonition-title,.wy-alert.wy-alert-info .wy-alert-title{background:#6ab0de}.rst-content .hint,.rst-content .important,.rst-content .tip,.rst-content .wy-alert-success.admonition,.rst-content .wy-alert-success.admonition-todo,.rst-content .wy-alert-success.attention,.rst-content .wy-alert-success.caution,.rst-content .wy-alert-success.danger,.rst-content .wy-alert-success.error,.rst-content .wy-alert-success.note,.rst-content .wy-alert-success.seealso,.rst-content .wy-alert-success.warning,.wy-alert.wy-alert-success{background:#dbfaf4}.rst-content .hint .admonition-title,.rst-content .hint .wy-alert-title,.rst-content .important .admonition-title,.rst-content .important .wy-alert-title,.rst-content .tip .admonition-title,.rst-content .tip .wy-alert-title,.rst-content .wy-alert-success.admonition-todo .admonition-title,.rst-content .wy-alert-success.admonition-todo .wy-alert-title,.rst-content .wy-alert-success.admonition .admonition-title,.rst-content .wy-alert-success.admonition .wy-alert-title,.rst-content .wy-alert-success.attention .admonition-title,.rst-content .wy-alert-success.attention .wy-alert-title,.rst-content .wy-alert-success.caution .admonition-title,.rst-content .wy-alert-success.caution .wy-alert-title,.rst-content .wy-alert-success.danger .admonition-title,.rst-content .wy-alert-success.danger .wy-alert-title,.rst-content .wy-alert-success.error .admonition-title,.rst-content .wy-alert-success.error .wy-alert-title,.rst-content .wy-alert-success.note .admonition-title,.rst-content .wy-alert-success.note .wy-alert-title,.rst-content .wy-alert-success.seealso .admonition-title,.rst-content .wy-alert-success.seealso .wy-alert-title,.rst-content .wy-alert-success.warning .admonition-title,.rst-content .wy-alert-success.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-success .admonition-title,.wy-alert.wy-alert-success .rst-content .admonition-title,.wy-alert.wy-alert-success .wy-alert-title{background:#1abc9c}.rst-content .wy-alert-neutral.admonition,.rst-content .wy-alert-neutral.admonition-todo,.rst-content .wy-alert-neutral.attention,.rst-content .wy-alert-neutral.caution,.rst-content .wy-alert-neutral.danger,.rst-content .wy-alert-neutral.error,.rst-content .wy-alert-neutral.hint,.rst-content .wy-alert-neutral.important,.rst-content .wy-alert-neutral.note,.rst-content .wy-alert-neutral.seealso,.rst-content .wy-alert-neutral.tip,.rst-content .wy-alert-neutral.warning,.wy-alert.wy-alert-neutral{background:#f3f6f6}.rst-content .wy-alert-neutral.admonition-todo .admonition-title,.rst-content .wy-alert-neutral.admonition-todo .wy-alert-title,.rst-content .wy-alert-neutral.admonition .admonition-title,.rst-content .wy-alert-neutral.admonition .wy-alert-title,.rst-content .wy-alert-neutral.attention .admonition-title,.rst-content .wy-alert-neutral.attention .wy-alert-title,.rst-content .wy-alert-neutral.caution .admonition-title,.rst-content .wy-alert-neutral.caution .wy-alert-title,.rst-content .wy-alert-neutral.danger .admonition-title,.rst-content .wy-alert-neutral.danger .wy-alert-title,.rst-content .wy-alert-neutral.error .admonition-title,.rst-content .wy-alert-neutral.error .wy-alert-title,.rst-content .wy-alert-neutral.hint .admonition-title,.rst-content .wy-alert-neutral.hint .wy-alert-title,.rst-content .wy-alert-neutral.important .admonition-title,.rst-content .wy-alert-neutral.important .wy-alert-title,.rst-content .wy-alert-neutral.note .admonition-title,.rst-content .wy-alert-neutral.note .wy-alert-title,.rst-content .wy-alert-neutral.seealso .admonition-title,.rst-content .wy-alert-neutral.seealso .wy-alert-title,.rst-content .wy-alert-neutral.tip .admonition-title,.rst-content .wy-alert-neutral.tip .wy-alert-title,.rst-content .wy-alert-neutral.warning .admonition-title,.rst-content .wy-alert-neutral.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-neutral .admonition-title,.wy-alert.wy-alert-neutral .rst-content .admonition-title,.wy-alert.wy-alert-neutral .wy-alert-title{color:#404040;background:#e1e4e5}.rst-content .wy-alert-neutral.admonition-todo a,.rst-content .wy-alert-neutral.admonition a,.rst-content .wy-alert-neutral.attention a,.rst-content .wy-alert-neutral.caution a,.rst-content .wy-alert-neutral.danger a,.rst-content .wy-alert-neutral.error a,.rst-content .wy-alert-neutral.hint a,.rst-content .wy-alert-neutral.important a,.rst-content .wy-alert-neutral.note a,.rst-content .wy-alert-neutral.seealso a,.rst-content .wy-alert-neutral.tip a,.rst-content .wy-alert-neutral.warning a,.wy-alert.wy-alert-neutral a{color:#2980b9}.rst-content .admonition-todo p:last-child,.rst-content .admonition p:last-child,.rst-content .attention p:last-child,.rst-content .caution p:last-child,.rst-content .danger p:last-child,.rst-content .error p:last-child,.rst-content .hint p:last-child,.rst-content .important p:last-child,.rst-content .note p:last-child,.rst-content .seealso p:last-child,.rst-content .tip p:last-child,.rst-content .warning p:last-child,.wy-alert p:last-child{margin-bottom:0}.wy-tray-container{position:fixed;bottom:0;left:0;z-index:600}.wy-tray-container li{display:block;width:300px;background:transparent;color:#fff;text-align:center;box-shadow:0 5px 5px 0 rgba(0,0,0,.1);padding:0 24px;min-width:20%;opacity:0;height:0;line-height:56px;overflow:hidden;-webkit-transition:all .3s ease-in;-moz-transition:all .3s ease-in;transition:all .3s ease-in}.wy-tray-container li.wy-tray-item-success{background:#27ae60}.wy-tray-container li.wy-tray-item-info{background:#2980b9}.wy-tray-container li.wy-tray-item-warning{background:#e67e22}.wy-tray-container li.wy-tray-item-danger{background:#e74c3c}.wy-tray-container li.on{opacity:1;height:56px}@media screen and (max-width:768px){.wy-tray-container{bottom:auto;top:0;width:100%}.wy-tray-container li{width:100%}}button{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle;cursor:pointer;line-height:normal;-webkit-appearance:button;*overflow:visible}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}button[disabled]{cursor:default}.btn{display:inline-block;border-radius:2px;line-height:normal;white-space:nowrap;text-align:center;cursor:pointer;font-size:100%;padding:6px 12px 8px;color:#fff;border:1px solid rgba(0,0,0,.1);background-color:#27ae60;text-decoration:none;font-weight:400;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;box-shadow:inset 0 1px 2px -1px hsla(0,0%,100%,.5),inset 0 -2px 0 0 rgba(0,0,0,.1);outline-none:false;vertical-align:middle;*display:inline;zoom:1;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transition:all .1s linear;-moz-transition:all .1s linear;transition:all .1s linear}.btn-hover{background:#2e8ece;color:#fff}.btn:hover{background:#2cc36b;color:#fff}.btn:focus{background:#2cc36b;outline:0}.btn:active{box-shadow:inset 0 -1px 0 0 rgba(0,0,0,.05),inset 0 2px 0 0 rgba(0,0,0,.1);padding:8px 12px 6px}.btn:visited{color:#fff}.btn-disabled,.btn-disabled:active,.btn-disabled:focus,.btn-disabled:hover,.btn:disabled{background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=40);opacity:.4;cursor:not-allowed;box-shadow:none}.btn::-moz-focus-inner{padding:0;border:0}.btn-small{font-size:80%}.btn-info{background-color:#2980b9!important}.btn-info:hover{background-color:#2e8ece!important}.btn-neutral{background-color:#f3f6f6!important;color:#404040!important}.btn-neutral:hover{background-color:#e5ebeb!important;color:#404040}.btn-neutral:visited{color:#404040!important}.btn-success{background-color:#27ae60!important}.btn-success:hover{background-color:#295!important}.btn-danger{background-color:#e74c3c!important}.btn-danger:hover{background-color:#ea6153!important}.btn-warning{background-color:#e67e22!important}.btn-warning:hover{background-color:#e98b39!important}.btn-invert{background-color:#222}.btn-invert:hover{background-color:#2f2f2f!important}.btn-link{background-color:transparent!important;color:#2980b9;box-shadow:none;border-color:transparent!important}.btn-link:active,.btn-link:hover{background-color:transparent!important;color:#409ad5!important;box-shadow:none}.btn-link:visited{color:#9b59b6}.wy-btn-group .btn,.wy-control .btn{vertical-align:middle}.wy-btn-group{margin-bottom:24px;*zoom:1}.wy-btn-group:after,.wy-btn-group:before{display:table;content:""}.wy-btn-group:after{clear:both}.wy-dropdown{position:relative;display:inline-block}.wy-dropdown-active .wy-dropdown-menu{display:block}.wy-dropdown-menu{position:absolute;left:0;display:none;float:left;top:100%;min-width:100%;background:#fcfcfc;z-index:100;border:1px solid #cfd7dd;box-shadow:0 2px 2px 0 rgba(0,0,0,.1);padding:12px}.wy-dropdown-menu>dd>a{display:block;clear:both;color:#404040;white-space:nowrap;font-size:90%;padding:0 12px;cursor:pointer}.wy-dropdown-menu>dd>a:hover{background:#2980b9;color:#fff}.wy-dropdown-menu>dd.divider{border-top:1px solid #cfd7dd;margin:6px 0}.wy-dropdown-menu>dd.search{padding-bottom:12px}.wy-dropdown-menu>dd.search input[type=search]{width:100%}.wy-dropdown-menu>dd.call-to-action{background:#e3e3e3;text-transform:uppercase;font-weight:500;font-size:80%}.wy-dropdown-menu>dd.call-to-action:hover{background:#e3e3e3}.wy-dropdown-menu>dd.call-to-action .btn{color:#fff}.wy-dropdown.wy-dropdown-up .wy-dropdown-menu{bottom:100%;top:auto;left:auto;right:0}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu{background:#fcfcfc;margin-top:2px}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a{padding:6px 12px}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a:hover{background:#2980b9;color:#fff}.wy-dropdown.wy-dropdown-left .wy-dropdown-menu{right:0;left:auto;text-align:right}.wy-dropdown-arrow:before{content:" ";border-bottom:5px solid #f5f5f5;border-left:5px solid transparent;border-right:5px solid transparent;position:absolute;display:block;top:-4px;left:50%;margin-left:-3px}.wy-dropdown-arrow.wy-dropdown-arrow-left:before{left:11px}.wy-form-stacked select{display:block}.wy-form-aligned .wy-help-inline,.wy-form-aligned input,.wy-form-aligned label,.wy-form-aligned select,.wy-form-aligned textarea{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.wy-form-aligned .wy-control-group>label{display:inline-block;vertical-align:middle;width:10em;margin:6px 12px 0 0;float:left}.wy-form-aligned .wy-control{float:left}.wy-form-aligned .wy-control label{display:block}.wy-form-aligned .wy-control select{margin-top:6px}fieldset{margin:0}fieldset,legend{border:0;padding:0}legend{width:100%;white-space:normal;margin-bottom:24px;font-size:150%;*margin-left:-7px}label,legend{display:block}label{margin:0 0 .3125em;color:#333;font-size:90%}input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}.wy-control-group{margin-bottom:24px;max-width:1200px;margin-left:auto;margin-right:auto;*zoom:1}.wy-control-group:after,.wy-control-group:before{display:table;content:""}.wy-control-group:after{clear:both}.wy-control-group.wy-control-group-required>label:after{content:" *";color:#e74c3c}.wy-control-group .wy-form-full,.wy-control-group .wy-form-halves,.wy-control-group .wy-form-thirds{padding-bottom:12px}.wy-control-group .wy-form-full input[type=color],.wy-control-group .wy-form-full input[type=date],.wy-control-group .wy-form-full input[type=datetime-local],.wy-control-group .wy-form-full input[type=datetime],.wy-control-group .wy-form-full input[type=email],.wy-control-group .wy-form-full input[type=month],.wy-control-group .wy-form-full input[type=number],.wy-control-group .wy-form-full input[type=password],.wy-control-group .wy-form-full input[type=search],.wy-control-group .wy-form-full input[type=tel],.wy-control-group .wy-form-full input[type=text],.wy-control-group .wy-form-full input[type=time],.wy-control-group .wy-form-full input[type=url],.wy-control-group .wy-form-full input[type=week],.wy-control-group .wy-form-full select,.wy-control-group .wy-form-halves input[type=color],.wy-control-group .wy-form-halves input[type=date],.wy-control-group .wy-form-halves input[type=datetime-local],.wy-control-group .wy-form-halves input[type=datetime],.wy-control-group .wy-form-halves input[type=email],.wy-control-group .wy-form-halves input[type=month],.wy-control-group .wy-form-halves input[type=number],.wy-control-group .wy-form-halves input[type=password],.wy-control-group .wy-form-halves input[type=search],.wy-control-group .wy-form-halves input[type=tel],.wy-control-group .wy-form-halves input[type=text],.wy-control-group .wy-form-halves input[type=time],.wy-control-group .wy-form-halves input[type=url],.wy-control-group .wy-form-halves input[type=week],.wy-control-group .wy-form-halves select,.wy-control-group .wy-form-thirds input[type=color],.wy-control-group .wy-form-thirds input[type=date],.wy-control-group .wy-form-thirds input[type=datetime-local],.wy-control-group .wy-form-thirds input[type=datetime],.wy-control-group .wy-form-thirds input[type=email],.wy-control-group .wy-form-thirds input[type=month],.wy-control-group .wy-form-thirds input[type=number],.wy-control-group .wy-form-thirds input[type=password],.wy-control-group .wy-form-thirds input[type=search],.wy-control-group .wy-form-thirds input[type=tel],.wy-control-group .wy-form-thirds input[type=text],.wy-control-group .wy-form-thirds input[type=time],.wy-control-group .wy-form-thirds input[type=url],.wy-control-group .wy-form-thirds input[type=week],.wy-control-group .wy-form-thirds select{width:100%}.wy-control-group .wy-form-full{float:left;display:block;width:100%;margin-right:0}.wy-control-group .wy-form-full:last-child{margin-right:0}.wy-control-group .wy-form-halves{float:left;display:block;margin-right:2.35765%;width:48.82117%}.wy-control-group .wy-form-halves:last-child,.wy-control-group .wy-form-halves:nth-of-type(2n){margin-right:0}.wy-control-group .wy-form-halves:nth-of-type(odd){clear:left}.wy-control-group .wy-form-thirds{float:left;display:block;margin-right:2.35765%;width:31.76157%}.wy-control-group .wy-form-thirds:last-child,.wy-control-group .wy-form-thirds:nth-of-type(3n){margin-right:0}.wy-control-group .wy-form-thirds:nth-of-type(3n+1){clear:left}.wy-control-group.wy-control-group-no-input .wy-control,.wy-control-no-input{margin:6px 0 0;font-size:90%}.wy-control-no-input{display:inline-block}.wy-control-group.fluid-input input[type=color],.wy-control-group.fluid-input input[type=date],.wy-control-group.fluid-input input[type=datetime-local],.wy-control-group.fluid-input input[type=datetime],.wy-control-group.fluid-input input[type=email],.wy-control-group.fluid-input input[type=month],.wy-control-group.fluid-input input[type=number],.wy-control-group.fluid-input input[type=password],.wy-control-group.fluid-input input[type=search],.wy-control-group.fluid-input input[type=tel],.wy-control-group.fluid-input input[type=text],.wy-control-group.fluid-input input[type=time],.wy-control-group.fluid-input input[type=url],.wy-control-group.fluid-input input[type=week]{width:100%}.wy-form-message-inline{padding-left:.3em;color:#666;font-size:90%}.wy-form-message{display:block;color:#999;font-size:70%;margin-top:.3125em;font-style:italic}.wy-form-message p{font-size:inherit;font-style:italic;margin-bottom:6px}.wy-form-message p:last-child{margin-bottom:0}input{line-height:normal}input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;*overflow:visible}input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week]{-webkit-appearance:none;padding:6px;display:inline-block;border:1px solid #ccc;font-size:80%;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;box-shadow:inset 0 1px 3px #ddd;border-radius:0;-webkit-transition:border .3s linear;-moz-transition:border .3s linear;transition:border .3s linear}input[type=datetime-local]{padding:.34375em .625em}input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{padding:0;margin-right:.3125em;*height:13px;*width:13px}input[type=checkbox],input[type=radio],input[type=search]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}input[type=color]:focus,input[type=date]:focus,input[type=datetime-local]:focus,input[type=datetime]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,input[type=password]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus{outline:0;outline:thin dotted\9;border-color:#333}input.no-focus:focus{border-color:#ccc!important}input[type=checkbox]:focus,input[type=file]:focus,input[type=radio]:focus{outline:thin dotted #333;outline:1px auto #129fea}input[type=color][disabled],input[type=date][disabled],input[type=datetime-local][disabled],input[type=datetime][disabled],input[type=email][disabled],input[type=month][disabled],input[type=number][disabled],input[type=password][disabled],input[type=search][disabled],input[type=tel][disabled],input[type=text][disabled],input[type=time][disabled],input[type=url][disabled],input[type=week][disabled]{cursor:not-allowed;background-color:#fafafa}input:focus:invalid,select:focus:invalid,textarea:focus:invalid{color:#e74c3c;border:1px solid #e74c3c}input:focus:invalid:focus,select:focus:invalid:focus,textarea:focus:invalid:focus{border-color:#e74c3c}input[type=checkbox]:focus:invalid:focus,input[type=file]:focus:invalid:focus,input[type=radio]:focus:invalid:focus{outline-color:#e74c3c}input.wy-input-large{padding:12px;font-size:100%}textarea{overflow:auto;vertical-align:top;width:100%;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif}select,textarea{padding:.5em .625em;display:inline-block;border:1px solid #ccc;font-size:80%;box-shadow:inset 0 1px 3px #ddd;-webkit-transition:border .3s linear;-moz-transition:border .3s linear;transition:border .3s linear}select{border:1px solid #ccc;background-color:#fff}select[multiple]{height:auto}select:focus,textarea:focus{outline:0}input[readonly],select[disabled],select[readonly],textarea[disabled],textarea[readonly]{cursor:not-allowed;background-color:#fafafa}input[type=checkbox][disabled],input[type=radio][disabled]{cursor:not-allowed}.wy-checkbox,.wy-radio{margin:6px 0;color:#404040;display:block}.wy-checkbox input,.wy-radio input{vertical-align:baseline}.wy-form-message-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.wy-input-prefix,.wy-input-suffix{white-space:nowrap;padding:6px}.wy-input-prefix .wy-input-context,.wy-input-suffix .wy-input-context{line-height:27px;padding:0 8px;display:inline-block;font-size:80%;background-color:#f3f6f6;border:1px solid #ccc;color:#999}.wy-input-suffix .wy-input-context{border-left:0}.wy-input-prefix .wy-input-context{border-right:0}.wy-switch{position:relative;display:block;height:24px;margin-top:12px;cursor:pointer}.wy-switch:before{left:0;top:0;width:36px;height:12px;background:#ccc}.wy-switch:after,.wy-switch:before{position:absolute;content:"";display:block;border-radius:4px;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.wy-switch:after{width:18px;height:18px;background:#999;left:-3px;top:-3px}.wy-switch span{position:absolute;left:48px;display:block;font-size:12px;color:#ccc;line-height:1}.wy-switch.active:before{background:#1e8449}.wy-switch.active:after{left:24px;background:#27ae60}.wy-switch.disabled{cursor:not-allowed;opacity:.8}.wy-control-group.wy-control-group-error .wy-form-message,.wy-control-group.wy-control-group-error>label{color:#e74c3c}.wy-control-group.wy-control-group-error input[type=color],.wy-control-group.wy-control-group-error input[type=date],.wy-control-group.wy-control-group-error input[type=datetime-local],.wy-control-group.wy-control-group-error input[type=datetime],.wy-control-group.wy-control-group-error input[type=email],.wy-control-group.wy-control-group-error input[type=month],.wy-control-group.wy-control-group-error input[type=number],.wy-control-group.wy-control-group-error input[type=password],.wy-control-group.wy-control-group-error input[type=search],.wy-control-group.wy-control-group-error input[type=tel],.wy-control-group.wy-control-group-error input[type=text],.wy-control-group.wy-control-group-error input[type=time],.wy-control-group.wy-control-group-error input[type=url],.wy-control-group.wy-control-group-error input[type=week],.wy-control-group.wy-control-group-error textarea{border:1px solid #e74c3c}.wy-inline-validate{white-space:nowrap}.wy-inline-validate .wy-input-context{padding:.5em .625em;display:inline-block;font-size:80%}.wy-inline-validate.wy-inline-validate-success .wy-input-context{color:#27ae60}.wy-inline-validate.wy-inline-validate-danger .wy-input-context{color:#e74c3c}.wy-inline-validate.wy-inline-validate-warning .wy-input-context{color:#e67e22}.wy-inline-validate.wy-inline-validate-info .wy-input-context{color:#2980b9}.rotate-90{-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.rotate-180{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-ms-transform:rotate(180deg);-o-transform:rotate(180deg);transform:rotate(180deg)}.rotate-270{-webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-ms-transform:rotate(270deg);-o-transform:rotate(270deg);transform:rotate(270deg)}.mirror{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-ms-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1)}.mirror.rotate-90{-webkit-transform:scaleX(-1) rotate(90deg);-moz-transform:scaleX(-1) rotate(90deg);-ms-transform:scaleX(-1) rotate(90deg);-o-transform:scaleX(-1) rotate(90deg);transform:scaleX(-1) rotate(90deg)}.mirror.rotate-180{-webkit-transform:scaleX(-1) rotate(180deg);-moz-transform:scaleX(-1) rotate(180deg);-ms-transform:scaleX(-1) rotate(180deg);-o-transform:scaleX(-1) rotate(180deg);transform:scaleX(-1) rotate(180deg)}.mirror.rotate-270{-webkit-transform:scaleX(-1) rotate(270deg);-moz-transform:scaleX(-1) rotate(270deg);-ms-transform:scaleX(-1) rotate(270deg);-o-transform:scaleX(-1) rotate(270deg);transform:scaleX(-1) rotate(270deg)}@media only screen and (max-width:480px){.wy-form button[type=submit]{margin:.7em 0 0}.wy-form input[type=color],.wy-form input[type=date],.wy-form input[type=datetime-local],.wy-form input[type=datetime],.wy-form input[type=email],.wy-form input[type=month],.wy-form input[type=number],.wy-form input[type=password],.wy-form input[type=search],.wy-form input[type=tel],.wy-form input[type=text],.wy-form input[type=time],.wy-form input[type=url],.wy-form input[type=week],.wy-form label{margin-bottom:.3em;display:block}.wy-form input[type=color],.wy-form input[type=date],.wy-form input[type=datetime-local],.wy-form input[type=datetime],.wy-form input[type=email],.wy-form input[type=month],.wy-form input[type=number],.wy-form input[type=password],.wy-form input[type=search],.wy-form input[type=tel],.wy-form input[type=time],.wy-form input[type=url],.wy-form input[type=week]{margin-bottom:0}.wy-form-aligned .wy-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.wy-form-aligned .wy-control{margin:1.5em 0 0}.wy-form-message,.wy-form-message-inline,.wy-form .wy-help-inline{display:block;font-size:80%;padding:6px 0}}@media screen and (max-width:768px){.tablet-hide{display:none}}@media screen and (max-width:480px){.mobile-hide{display:none}}.float-left{float:left}.float-right{float:right}.full-width{width:100%}.rst-content table.docutils,.rst-content table.field-list,.wy-table{border-collapse:collapse;border-spacing:0;empty-cells:show;margin-bottom:24px}.rst-content table.docutils caption,.rst-content table.field-list caption,.wy-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.rst-content table.docutils td,.rst-content table.docutils th,.rst-content table.field-list td,.rst-content table.field-list th,.wy-table td,.wy-table th{font-size:90%;margin:0;overflow:visible;padding:8px 16px}.rst-content table.docutils td:first-child,.rst-content table.docutils th:first-child,.rst-content table.field-list td:first-child,.rst-content table.field-list th:first-child,.wy-table td:first-child,.wy-table th:first-child{border-left-width:0}.rst-content table.docutils thead,.rst-content table.field-list thead,.wy-table thead{color:#000;text-align:left;vertical-align:bottom;white-space:nowrap}.rst-content table.docutils thead th,.rst-content table.field-list thead th,.wy-table thead th{font-weight:700;border-bottom:2px solid #e1e4e5}.rst-content table.docutils td,.rst-content table.field-list td,.wy-table td{background-color:transparent;vertical-align:middle}.rst-content table.docutils td p,.rst-content table.field-list td p,.wy-table td p{line-height:18px}.rst-content table.docutils td p:last-child,.rst-content table.field-list td p:last-child,.wy-table td p:last-child{margin-bottom:0}.rst-content table.docutils .wy-table-cell-min,.rst-content table.field-list .wy-table-cell-min,.wy-table .wy-table-cell-min{width:1%;padding-right:0}.rst-content table.docutils .wy-table-cell-min input[type=checkbox],.rst-content table.field-list .wy-table-cell-min input[type=checkbox],.wy-table .wy-table-cell-min input[type=checkbox]{margin:0}.wy-table-secondary{color:grey;font-size:90%}.wy-table-tertiary{color:grey;font-size:80%}.rst-content table.docutils:not(.field-list) tr:nth-child(2n-1) td,.wy-table-backed,.wy-table-odd td,.wy-table-striped tr:nth-child(2n-1) td{background-color:#f3f6f6}.rst-content table.docutils,.wy-table-bordered-all{border:1px solid #e1e4e5}.rst-content table.docutils td,.wy-table-bordered-all td{border-bottom:1px solid #e1e4e5;border-left:1px solid #e1e4e5}.rst-content table.docutils tbody>tr:last-child td,.wy-table-bordered-all tbody>tr:last-child td{border-bottom-width:0}.wy-table-bordered{border:1px solid #e1e4e5}.wy-table-bordered-rows td{border-bottom:1px solid #e1e4e5}.wy-table-bordered-rows tbody>tr:last-child td{border-bottom-width:0}.wy-table-horizontal td,.wy-table-horizontal th{border-width:0 0 1px;border-bottom:1px solid #e1e4e5}.wy-table-horizontal tbody>tr:last-child td{border-bottom-width:0}.wy-table-responsive{margin-bottom:24px;max-width:100%;overflow:auto}.wy-table-responsive table{margin-bottom:0!important}.wy-table-responsive table td,.wy-table-responsive table th{white-space:nowrap}a{color:#2980b9;text-decoration:none;cursor:pointer}a:hover{color:#3091d1}a:visited{color:#9b59b6}html{height:100%}body,html{overflow-x:hidden}body{font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;font-weight:400;color:#404040;min-height:100%;background:#edf0f2}.wy-text-left{text-align:left}.wy-text-center{text-align:center}.wy-text-right{text-align:right}.wy-text-large{font-size:120%}.wy-text-normal{font-size:100%}.wy-text-small,small{font-size:80%}.wy-text-strike{text-decoration:line-through}.wy-text-warning{color:#e67e22!important}a.wy-text-warning:hover{color:#eb9950!important}.wy-text-info{color:#2980b9!important}a.wy-text-info:hover{color:#409ad5!important}.wy-text-success{color:#27ae60!important}a.wy-text-success:hover{color:#36d278!important}.wy-text-danger{color:#e74c3c!important}a.wy-text-danger:hover{color:#ed7669!important}.wy-text-neutral{color:#404040!important}a.wy-text-neutral:hover{color:#595959!important}.rst-content .toctree-wrapper>p.caption,h1,h2,h3,h4,h5,h6,legend{margin-top:0;font-weight:700;font-family:Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif}p{line-height:24px;font-size:16px;margin:0 0 24px}h1{font-size:175%}.rst-content .toctree-wrapper>p.caption,h2{font-size:150%}h3{font-size:125%}h4{font-size:115%}h5{font-size:110%}h6{font-size:100%}hr{display:block;height:1px;border:0;border-top:1px solid #e1e4e5;margin:24px 0;padding:0}.rst-content code,.rst-content tt,code{white-space:nowrap;max-width:100%;background:#fff;border:1px solid #e1e4e5;font-size:75%;padding:0 5px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;color:#e74c3c;overflow-x:auto}.rst-content tt.code-large,code.code-large{font-size:90%}.rst-content .section ul,.rst-content .toctree-wrapper ul,.rst-content section ul,.wy-plain-list-disc,article ul{list-style:disc;line-height:24px;margin-bottom:24px}.rst-content .section ul li,.rst-content .toctree-wrapper ul li,.rst-content section ul li,.wy-plain-list-disc li,article ul li{list-style:disc;margin-left:24px}.rst-content .section ul li p:last-child,.rst-content .section ul li ul,.rst-content .toctree-wrapper ul li p:last-child,.rst-content .toctree-wrapper ul li ul,.rst-content section ul li p:last-child,.rst-content section ul li ul,.wy-plain-list-disc li p:last-child,.wy-plain-list-disc li ul,article ul li p:last-child,article ul li ul{margin-bottom:0}.rst-content .section ul li li,.rst-content .toctree-wrapper ul li li,.rst-content section ul li li,.wy-plain-list-disc li li,article ul li li{list-style:circle}.rst-content .section ul li li li,.rst-content .toctree-wrapper ul li li li,.rst-content section ul li li li,.wy-plain-list-disc li li li,article ul li li li{list-style:square}.rst-content .section ul li ol li,.rst-content .toctree-wrapper ul li ol li,.rst-content section ul li ol li,.wy-plain-list-disc li ol li,article ul li ol li{list-style:decimal}.rst-content .section ol,.rst-content .section ol.arabic,.rst-content .toctree-wrapper ol,.rst-content .toctree-wrapper ol.arabic,.rst-content section ol,.rst-content section ol.arabic,.wy-plain-list-decimal,article ol{list-style:decimal;line-height:24px;margin-bottom:24px}.rst-content .section ol.arabic li,.rst-content .section ol li,.rst-content .toctree-wrapper ol.arabic li,.rst-content .toctree-wrapper ol li,.rst-content section ol.arabic li,.rst-content section ol li,.wy-plain-list-decimal li,article ol li{list-style:decimal;margin-left:24px}.rst-content .section ol.arabic li ul,.rst-content .section ol li p:last-child,.rst-content .section ol li ul,.rst-content .toctree-wrapper ol.arabic li ul,.rst-content .toctree-wrapper ol li p:last-child,.rst-content .toctree-wrapper ol li ul,.rst-content section ol.arabic li ul,.rst-content section ol li p:last-child,.rst-content section ol li ul,.wy-plain-list-decimal li p:last-child,.wy-plain-list-decimal li ul,article ol li p:last-child,article ol li ul{margin-bottom:0}.rst-content .section ol.arabic li ul li,.rst-content .section ol li ul li,.rst-content .toctree-wrapper ol.arabic li ul li,.rst-content .toctree-wrapper ol li ul li,.rst-content section ol.arabic li ul li,.rst-content section ol li ul li,.wy-plain-list-decimal li ul li,article ol li ul li{list-style:disc}.wy-breadcrumbs{*zoom:1}.wy-breadcrumbs:after,.wy-breadcrumbs:before{display:table;content:""}.wy-breadcrumbs:after{clear:both}.wy-breadcrumbs>li{display:inline-block;padding-top:5px}.wy-breadcrumbs>li.wy-breadcrumbs-aside{float:right}.rst-content .wy-breadcrumbs>li code,.rst-content .wy-breadcrumbs>li tt,.wy-breadcrumbs>li .rst-content tt,.wy-breadcrumbs>li code{all:inherit;color:inherit}.breadcrumb-item:before{content:"/";color:#bbb;font-size:13px;padding:0 6px 0 3px}.wy-breadcrumbs-extra{margin-bottom:0;color:#b3b3b3;font-size:80%;display:inline-block}@media screen and (max-width:480px){.wy-breadcrumbs-extra,.wy-breadcrumbs li.wy-breadcrumbs-aside{display:none}}@media print{.wy-breadcrumbs li.wy-breadcrumbs-aside{display:none}}html{font-size:16px}.wy-affix{position:fixed;top:1.618em}.wy-menu a:hover{text-decoration:none}.wy-menu-horiz{*zoom:1}.wy-menu-horiz:after,.wy-menu-horiz:before{display:table;content:""}.wy-menu-horiz:after{clear:both}.wy-menu-horiz li,.wy-menu-horiz ul{display:inline-block}.wy-menu-horiz li:hover{background:hsla(0,0%,100%,.1)}.wy-menu-horiz li.divide-left{border-left:1px solid #404040}.wy-menu-horiz li.divide-right{border-right:1px solid #404040}.wy-menu-horiz a{height:32px;display:inline-block;line-height:32px;padding:0 16px}.wy-menu-vertical{width:300px}.wy-menu-vertical header,.wy-menu-vertical p.caption{color:#55a5d9;height:32px;line-height:32px;padding:0 1.618em;margin:12px 0 0;display:block;font-weight:700;text-transform:uppercase;font-size:85%;white-space:nowrap}.wy-menu-vertical ul{margin-bottom:0}.wy-menu-vertical li.divide-top{border-top:1px solid #404040}.wy-menu-vertical li.divide-bottom{border-bottom:1px solid #404040}.wy-menu-vertical li.current{background:#e3e3e3}.wy-menu-vertical li.current a{color:grey;border-right:1px solid #c9c9c9;padding:.4045em 2.427em}.wy-menu-vertical li.current a:hover{background:#d6d6d6}.rst-content .wy-menu-vertical li tt,.wy-menu-vertical li .rst-content tt,.wy-menu-vertical li code{border:none;background:inherit;color:inherit;padding-left:0;padding-right:0}.wy-menu-vertical li button.toctree-expand{display:block;float:left;margin-left:-1.2em;line-height:18px;color:#4d4d4d;border:none;background:none;padding:0}.wy-menu-vertical li.current>a,.wy-menu-vertical li.on a{color:#404040;font-weight:700;position:relative;background:#fcfcfc;border:none;padding:.4045em 1.618em}.wy-menu-vertical li.current>a:hover,.wy-menu-vertical li.on a:hover{background:#fcfcfc}.wy-menu-vertical li.current>a:hover button.toctree-expand,.wy-menu-vertical li.on a:hover button.toctree-expand{color:grey}.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand{display:block;line-height:18px;color:#333}.wy-menu-vertical li.toctree-l1.current>a{border-bottom:1px solid #c9c9c9;border-top:1px solid #c9c9c9}.wy-menu-vertical .toctree-l1.current .toctree-l2>ul,.wy-menu-vertical .toctree-l2.current .toctree-l3>ul,.wy-menu-vertical .toctree-l3.current .toctree-l4>ul,.wy-menu-vertical .toctree-l4.current .toctree-l5>ul,.wy-menu-vertical .toctree-l5.current .toctree-l6>ul,.wy-menu-vertical .toctree-l6.current .toctree-l7>ul,.wy-menu-vertical .toctree-l7.current .toctree-l8>ul,.wy-menu-vertical .toctree-l8.current .toctree-l9>ul,.wy-menu-vertical .toctree-l9.current .toctree-l10>ul,.wy-menu-vertical .toctree-l10.current .toctree-l11>ul{display:none}.wy-menu-vertical .toctree-l1.current .current.toctree-l2>ul,.wy-menu-vertical .toctree-l2.current .current.toctree-l3>ul,.wy-menu-vertical .toctree-l3.current .current.toctree-l4>ul,.wy-menu-vertical .toctree-l4.current .current.toctree-l5>ul,.wy-menu-vertical .toctree-l5.current .current.toctree-l6>ul,.wy-menu-vertical .toctree-l6.current .current.toctree-l7>ul,.wy-menu-vertical .toctree-l7.current .current.toctree-l8>ul,.wy-menu-vertical .toctree-l8.current .current.toctree-l9>ul,.wy-menu-vertical .toctree-l9.current .current.toctree-l10>ul,.wy-menu-vertical .toctree-l10.current .current.toctree-l11>ul{display:block}.wy-menu-vertical li.toctree-l3,.wy-menu-vertical li.toctree-l4{font-size:.9em}.wy-menu-vertical li.toctree-l2 a,.wy-menu-vertical li.toctree-l3 a,.wy-menu-vertical li.toctree-l4 a,.wy-menu-vertical li.toctree-l5 a,.wy-menu-vertical li.toctree-l6 a,.wy-menu-vertical li.toctree-l7 a,.wy-menu-vertical li.toctree-l8 a,.wy-menu-vertical li.toctree-l9 a,.wy-menu-vertical li.toctree-l10 a{color:#404040}.wy-menu-vertical li.toctree-l2 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l3 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l4 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l5 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l6 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l7 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l8 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l9 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l10 a:hover button.toctree-expand{color:grey}.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a,.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a,.wy-menu-vertical li.toctree-l4.current li.toctree-l5>a,.wy-menu-vertical li.toctree-l5.current li.toctree-l6>a,.wy-menu-vertical li.toctree-l6.current li.toctree-l7>a,.wy-menu-vertical li.toctree-l7.current li.toctree-l8>a,.wy-menu-vertical li.toctree-l8.current li.toctree-l9>a,.wy-menu-vertical li.toctree-l9.current li.toctree-l10>a,.wy-menu-vertical li.toctree-l10.current li.toctree-l11>a{display:block}.wy-menu-vertical li.toctree-l2.current>a{padding:.4045em 2.427em}.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a{padding:.4045em 1.618em .4045em 4.045em}.wy-menu-vertical li.toctree-l3.current>a{padding:.4045em 4.045em}.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a{padding:.4045em 1.618em .4045em 5.663em}.wy-menu-vertical li.toctree-l4.current>a{padding:.4045em 5.663em}.wy-menu-vertical li.toctree-l4.current li.toctree-l5>a{padding:.4045em 1.618em .4045em 7.281em}.wy-menu-vertical li.toctree-l5.current>a{padding:.4045em 7.281em}.wy-menu-vertical li.toctree-l5.current li.toctree-l6>a{padding:.4045em 1.618em .4045em 8.899em}.wy-menu-vertical li.toctree-l6.current>a{padding:.4045em 8.899em}.wy-menu-vertical li.toctree-l6.current li.toctree-l7>a{padding:.4045em 1.618em .4045em 10.517em}.wy-menu-vertical li.toctree-l7.current>a{padding:.4045em 10.517em}.wy-menu-vertical li.toctree-l7.current li.toctree-l8>a{padding:.4045em 1.618em .4045em 12.135em}.wy-menu-vertical li.toctree-l8.current>a{padding:.4045em 12.135em}.wy-menu-vertical li.toctree-l8.current li.toctree-l9>a{padding:.4045em 1.618em .4045em 13.753em}.wy-menu-vertical li.toctree-l9.current>a{padding:.4045em 13.753em}.wy-menu-vertical li.toctree-l9.current li.toctree-l10>a{padding:.4045em 1.618em .4045em 15.371em}.wy-menu-vertical li.toctree-l10.current>a{padding:.4045em 15.371em}.wy-menu-vertical li.toctree-l10.current li.toctree-l11>a{padding:.4045em 1.618em .4045em 16.989em}.wy-menu-vertical li.toctree-l2.current>a,.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a{background:#c9c9c9}.wy-menu-vertical li.toctree-l2 button.toctree-expand{color:#a3a3a3}.wy-menu-vertical li.toctree-l3.current>a,.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a{background:#bdbdbd}.wy-menu-vertical li.toctree-l3 button.toctree-expand{color:#969696}.wy-menu-vertical li.current ul{display:block}.wy-menu-vertical li ul{margin-bottom:0;display:none}.wy-menu-vertical li ul li a{margin-bottom:0;color:#d9d9d9;font-weight:400}.wy-menu-vertical a{line-height:18px;padding:.4045em 1.618em;display:block;position:relative;font-size:90%;color:#d9d9d9}.wy-menu-vertical a:hover{background-color:#4e4a4a;cursor:pointer}.wy-menu-vertical a:hover button.toctree-expand{color:#d9d9d9}.wy-menu-vertical a:active{background-color:#2980b9;cursor:pointer;color:#fff}.wy-menu-vertical a:active button.toctree-expand{color:#fff}.wy-side-nav-search{display:block;width:300px;padding:.809em;margin-bottom:.809em;z-index:200;background-color:#2980b9;text-align:center;color:#fcfcfc}.wy-side-nav-search input[type=text]{width:100%;border-radius:50px;padding:6px 12px;border-color:#2472a4}.wy-side-nav-search img{display:block;margin:auto auto .809em;height:45px;width:45px;background-color:#2980b9;padding:5px;border-radius:100%}.wy-side-nav-search .wy-dropdown>a,.wy-side-nav-search>a{color:#fcfcfc;font-size:100%;font-weight:700;display:inline-block;padding:4px 6px;margin-bottom:.809em;max-width:100%}.wy-side-nav-search .wy-dropdown>a:hover,.wy-side-nav-search>a:hover{background:hsla(0,0%,100%,.1)}.wy-side-nav-search .wy-dropdown>a img.logo,.wy-side-nav-search>a img.logo{display:block;margin:0 auto;height:auto;width:auto;border-radius:0;max-width:100%;background:transparent}.wy-side-nav-search .wy-dropdown>a.icon img.logo,.wy-side-nav-search>a.icon img.logo{margin-top:.85em}.wy-side-nav-search>div.version{margin-top:-.4045em;margin-bottom:.809em;font-weight:400;color:hsla(0,0%,100%,.3)}.wy-nav .wy-menu-vertical header{color:#2980b9}.wy-nav .wy-menu-vertical a{color:#b3b3b3}.wy-nav .wy-menu-vertical a:hover{background-color:#2980b9;color:#fff}[data-menu-wrap]{-webkit-transition:all .2s ease-in;-moz-transition:all .2s ease-in;transition:all .2s ease-in;position:absolute;opacity:1;width:100%;opacity:0}[data-menu-wrap].move-center{left:0;right:auto;opacity:1}[data-menu-wrap].move-left{right:auto;left:-100%;opacity:0}[data-menu-wrap].move-right{right:-100%;left:auto;opacity:0}.wy-body-for-nav{background:#fcfcfc}.wy-grid-for-nav{position:absolute;width:100%;height:100%}.wy-nav-side{position:fixed;top:0;bottom:0;left:0;padding-bottom:2em;width:300px;overflow-x:hidden;overflow-y:hidden;min-height:100%;color:#9b9b9b;background:#343131;z-index:200}.wy-side-scroll{width:320px;position:relative;overflow-x:hidden;overflow-y:scroll;height:100%}.wy-nav-top{display:none;background:#2980b9;color:#fff;padding:.4045em .809em;position:relative;line-height:50px;text-align:center;font-size:100%;*zoom:1}.wy-nav-top:after,.wy-nav-top:before{display:table;content:""}.wy-nav-top:after{clear:both}.wy-nav-top a{color:#fff;font-weight:700}.wy-nav-top img{margin-right:12px;height:45px;width:45px;background-color:#2980b9;padding:5px;border-radius:100%}.wy-nav-top i{font-size:30px;float:left;cursor:pointer;padding-top:inherit}.wy-nav-content-wrap{margin-left:300px;background:#fcfcfc;min-height:100%}.wy-nav-content{padding:1.618em 3.236em;height:100%;max-width:800px;margin:auto}.wy-body-mask{position:fixed;width:100%;height:100%;background:rgba(0,0,0,.2);display:none;z-index:499}.wy-body-mask.on{display:block}footer{color:grey}footer p{margin-bottom:12px}.rst-content footer span.commit tt,footer span.commit .rst-content tt,footer span.commit code{padding:0;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;font-size:1em;background:none;border:none;color:grey}.rst-footer-buttons{*zoom:1}.rst-footer-buttons:after,.rst-footer-buttons:before{width:100%;display:table;content:""}.rst-footer-buttons:after{clear:both}.rst-breadcrumbs-buttons{margin-top:12px;*zoom:1}.rst-breadcrumbs-buttons:after,.rst-breadcrumbs-buttons:before{display:table;content:""}.rst-breadcrumbs-buttons:after{clear:both}#search-results .search li{margin-bottom:24px;border-bottom:1px solid #e1e4e5;padding-bottom:24px}#search-results .search li:first-child{border-top:1px solid #e1e4e5;padding-top:24px}#search-results .search li a{font-size:120%;margin-bottom:12px;display:inline-block}#search-results .context{color:grey;font-size:90%}.genindextable li>ul{margin-left:24px}@media screen and (max-width:768px){.wy-body-for-nav{background:#fcfcfc}.wy-nav-top{display:block}.wy-nav-side{left:-300px}.wy-nav-side.shift{width:85%;left:0}.wy-menu.wy-menu-vertical,.wy-side-nav-search,.wy-side-scroll{width:auto}.wy-nav-content-wrap{margin-left:0}.wy-nav-content-wrap .wy-nav-content{padding:1.618em}.wy-nav-content-wrap.shift{position:fixed;min-width:100%;left:85%;top:0;height:100%;overflow:hidden}}@media screen and (min-width:1100px){.wy-nav-content-wrap{background:rgba(0,0,0,.05)}.wy-nav-content{margin:0;background:#fcfcfc}}@media print{.rst-versions,.wy-nav-side,footer{display:none}.wy-nav-content-wrap{margin-left:0}}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60;*zoom:1}.rst-versions .rst-current-version:after,.rst-versions .rst-current-version:before{display:table;content:""}.rst-versions .rst-current-version:after{clear:both}.rst-content .code-block-caption .rst-versions .rst-current-version .headerlink,.rst-content .eqno .rst-versions .rst-current-version .headerlink,.rst-content .rst-versions .rst-current-version .admonition-title,.rst-content code.download .rst-versions .rst-current-version span:first-child,.rst-content dl dt .rst-versions .rst-current-version .headerlink,.rst-content h1 .rst-versions .rst-current-version .headerlink,.rst-content h2 .rst-versions .rst-current-version .headerlink,.rst-content h3 .rst-versions .rst-current-version .headerlink,.rst-content h4 .rst-versions .rst-current-version .headerlink,.rst-content h5 .rst-versions .rst-current-version .headerlink,.rst-content h6 .rst-versions .rst-current-version .headerlink,.rst-content p .rst-versions .rst-current-version .headerlink,.rst-content table>caption .rst-versions .rst-current-version .headerlink,.rst-content tt.download .rst-versions .rst-current-version span:first-child,.rst-versions .rst-current-version .fa,.rst-versions .rst-current-version .icon,.rst-versions .rst-current-version .rst-content .admonition-title,.rst-versions .rst-current-version .rst-content .code-block-caption .headerlink,.rst-versions .rst-current-version .rst-content .eqno .headerlink,.rst-versions .rst-current-version .rst-content code.download span:first-child,.rst-versions .rst-current-version .rst-content dl dt .headerlink,.rst-versions .rst-current-version .rst-content h1 .headerlink,.rst-versions .rst-current-version .rst-content h2 .headerlink,.rst-versions .rst-current-version .rst-content h3 .headerlink,.rst-versions .rst-current-version .rst-content h4 .headerlink,.rst-versions .rst-current-version .rst-content h5 .headerlink,.rst-versions .rst-current-version .rst-content h6 .headerlink,.rst-versions .rst-current-version .rst-content p .headerlink,.rst-versions .rst-current-version .rst-content table>caption .headerlink,.rst-versions .rst-current-version .rst-content tt.download span:first-child,.rst-versions .rst-current-version .wy-menu-vertical li button.toctree-expand,.wy-menu-vertical li .rst-versions .rst-current-version button.toctree-expand{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}.rst-content .toctree-wrapper>p.caption,.rst-content h1,.rst-content h2,.rst-content h3,.rst-content h4,.rst-content h5,.rst-content h6{margin-bottom:24px}.rst-content img{max-width:100%;height:auto}.rst-content div.figure,.rst-content figure{margin-bottom:24px}.rst-content div.figure .caption-text,.rst-content figure .caption-text{font-style:italic}.rst-content div.figure p:last-child.caption,.rst-content figure p:last-child.caption{margin-bottom:0}.rst-content div.figure.align-center,.rst-content figure.align-center{text-align:center}.rst-content .section>a>img,.rst-content .section>img,.rst-content section>a>img,.rst-content section>img{margin-bottom:24px}.rst-content abbr[title]{text-decoration:none}.rst-content.style-external-links a.reference.external:after{font-family:FontAwesome;content:"\f08e";color:#b3b3b3;vertical-align:super;font-size:60%;margin:0 .2em}.rst-content blockquote{margin-left:24px;line-height:24px;margin-bottom:24px}.rst-content pre.literal-block{white-space:pre;margin:0;padding:12px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;display:block;overflow:auto}.rst-content div[class^=highlight],.rst-content pre.literal-block{border:1px solid #e1e4e5;overflow-x:auto;margin:1px 0 24px}.rst-content div[class^=highlight] div[class^=highlight],.rst-content pre.literal-block div[class^=highlight]{padding:0;border:none;margin:0}.rst-content div[class^=highlight] td.code{width:100%}.rst-content .linenodiv pre{border-right:1px solid #e6e9ea;margin:0;padding:12px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;user-select:none;pointer-events:none}.rst-content div[class^=highlight] pre{white-space:pre;margin:0;padding:12px;display:block;overflow:auto}.rst-content div[class^=highlight] pre .hll{display:block;margin:0 -12px;padding:0 12px}.rst-content .linenodiv pre,.rst-content div[class^=highlight] pre,.rst-content pre.literal-block{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;font-size:12px;line-height:1.4}.rst-content div.highlight .gp,.rst-content div.highlight span.linenos{user-select:none;pointer-events:none}.rst-content div.highlight span.linenos{display:inline-block;padding-left:0;padding-right:12px;margin-right:12px;border-right:1px solid #e6e9ea}.rst-content .code-block-caption{font-style:italic;font-size:85%;line-height:1;padding:1em 0;text-align:center}@media print{.rst-content .codeblock,.rst-content div[class^=highlight],.rst-content div[class^=highlight] pre{white-space:pre-wrap}}.rst-content .admonition,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .danger,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning{clear:both}.rst-content .admonition-todo .last,.rst-content .admonition-todo>:last-child,.rst-content .admonition .last,.rst-content .admonition>:last-child,.rst-content .attention .last,.rst-content .attention>:last-child,.rst-content .caution .last,.rst-content .caution>:last-child,.rst-content .danger .last,.rst-content .danger>:last-child,.rst-content .error .last,.rst-content .error>:last-child,.rst-content .hint .last,.rst-content .hint>:last-child,.rst-content .important .last,.rst-content .important>:last-child,.rst-content .note .last,.rst-content .note>:last-child,.rst-content .seealso .last,.rst-content .seealso>:last-child,.rst-content .tip .last,.rst-content .tip>:last-child,.rst-content .warning .last,.rst-content .warning>:last-child{margin-bottom:0}.rst-content .admonition-title:before{margin-right:4px}.rst-content .admonition table{border-color:rgba(0,0,0,.1)}.rst-content .admonition table td,.rst-content .admonition table th{background:transparent!important;border-color:rgba(0,0,0,.1)!important}.rst-content .section ol.loweralpha,.rst-content .section ol.loweralpha>li,.rst-content .toctree-wrapper ol.loweralpha,.rst-content .toctree-wrapper ol.loweralpha>li,.rst-content section ol.loweralpha,.rst-content section ol.loweralpha>li{list-style:lower-alpha}.rst-content .section ol.upperalpha,.rst-content .section ol.upperalpha>li,.rst-content .toctree-wrapper ol.upperalpha,.rst-content .toctree-wrapper ol.upperalpha>li,.rst-content section ol.upperalpha,.rst-content section ol.upperalpha>li{list-style:upper-alpha}.rst-content .section ol li>*,.rst-content .section ul li>*,.rst-content .toctree-wrapper ol li>*,.rst-content .toctree-wrapper ul li>*,.rst-content section ol li>*,.rst-content section ul li>*{margin-top:12px;margin-bottom:12px}.rst-content .section ol li>:first-child,.rst-content .section ul li>:first-child,.rst-content .toctree-wrapper ol li>:first-child,.rst-content .toctree-wrapper ul li>:first-child,.rst-content section ol li>:first-child,.rst-content section ul li>:first-child{margin-top:0}.rst-content .section ol li>p,.rst-content .section ol li>p:last-child,.rst-content .section ul li>p,.rst-content .section ul li>p:last-child,.rst-content .toctree-wrapper ol li>p,.rst-content .toctree-wrapper ol li>p:last-child,.rst-content .toctree-wrapper ul li>p,.rst-content .toctree-wrapper ul li>p:last-child,.rst-content section ol li>p,.rst-content section ol li>p:last-child,.rst-content section ul li>p,.rst-content section ul li>p:last-child{margin-bottom:12px}.rst-content .section ol li>p:only-child,.rst-content .section ol li>p:only-child:last-child,.rst-content .section ul li>p:only-child,.rst-content .section ul li>p:only-child:last-child,.rst-content .toctree-wrapper ol li>p:only-child,.rst-content .toctree-wrapper ol li>p:only-child:last-child,.rst-content .toctree-wrapper ul li>p:only-child,.rst-content .toctree-wrapper ul li>p:only-child:last-child,.rst-content section ol li>p:only-child,.rst-content section ol li>p:only-child:last-child,.rst-content section ul li>p:only-child,.rst-content section ul li>p:only-child:last-child{margin-bottom:0}.rst-content .section ol li>ol,.rst-content .section ol li>ul,.rst-content .section ul li>ol,.rst-content .section ul li>ul,.rst-content .toctree-wrapper ol li>ol,.rst-content .toctree-wrapper ol li>ul,.rst-content .toctree-wrapper ul li>ol,.rst-content .toctree-wrapper ul li>ul,.rst-content section ol li>ol,.rst-content section ol li>ul,.rst-content section ul li>ol,.rst-content section ul li>ul{margin-bottom:12px}.rst-content .section ol.simple li>*,.rst-content .section ol.simple li ol,.rst-content .section ol.simple li ul,.rst-content .section ul.simple li>*,.rst-content .section ul.simple li ol,.rst-content .section ul.simple li ul,.rst-content .toctree-wrapper ol.simple li>*,.rst-content .toctree-wrapper ol.simple li ol,.rst-content .toctree-wrapper ol.simple li ul,.rst-content .toctree-wrapper ul.simple li>*,.rst-content .toctree-wrapper ul.simple li ol,.rst-content .toctree-wrapper ul.simple li ul,.rst-content section ol.simple li>*,.rst-content section ol.simple li ol,.rst-content section ol.simple li ul,.rst-content section ul.simple li>*,.rst-content section ul.simple li ol,.rst-content section ul.simple li ul{margin-top:0;margin-bottom:0}.rst-content .line-block{margin-left:0;margin-bottom:24px;line-height:24px}.rst-content .line-block .line-block{margin-left:24px;margin-bottom:0}.rst-content .topic-title{font-weight:700;margin-bottom:12px}.rst-content .toc-backref{color:#404040}.rst-content .align-right{float:right;margin:0 0 24px 24px}.rst-content .align-left{float:left;margin:0 24px 24px 0}.rst-content .align-center{margin:auto}.rst-content .align-center:not(table){display:block}.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content .toctree-wrapper>p.caption .headerlink,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink{opacity:0;font-size:14px;font-family:FontAwesome;margin-left:.5em}.rst-content .code-block-caption .headerlink:focus,.rst-content .code-block-caption:hover .headerlink,.rst-content .eqno .headerlink:focus,.rst-content .eqno:hover .headerlink,.rst-content .toctree-wrapper>p.caption .headerlink:focus,.rst-content .toctree-wrapper>p.caption:hover .headerlink,.rst-content dl dt .headerlink:focus,.rst-content dl dt:hover .headerlink,.rst-content h1 .headerlink:focus,.rst-content h1:hover .headerlink,.rst-content h2 .headerlink:focus,.rst-content h2:hover .headerlink,.rst-content h3 .headerlink:focus,.rst-content h3:hover .headerlink,.rst-content h4 .headerlink:focus,.rst-content h4:hover .headerlink,.rst-content h5 .headerlink:focus,.rst-content h5:hover .headerlink,.rst-content h6 .headerlink:focus,.rst-content h6:hover .headerlink,.rst-content p.caption .headerlink:focus,.rst-content p.caption:hover .headerlink,.rst-content p .headerlink:focus,.rst-content p:hover .headerlink,.rst-content table>caption .headerlink:focus,.rst-content table>caption:hover .headerlink{opacity:1}.rst-content p a{overflow-wrap:anywhere}.rst-content .wy-table td p,.rst-content .wy-table td ul,.rst-content .wy-table th p,.rst-content .wy-table th ul,.rst-content table.docutils td p,.rst-content table.docutils td ul,.rst-content table.docutils th p,.rst-content table.docutils th ul,.rst-content table.field-list td p,.rst-content table.field-list td ul,.rst-content table.field-list th p,.rst-content table.field-list th ul{font-size:inherit}.rst-content .btn:focus{outline:2px solid}.rst-content table>caption .headerlink:after{font-size:12px}.rst-content .centered{text-align:center}.rst-content .sidebar{float:right;width:40%;display:block;margin:0 0 24px 24px;padding:24px;background:#f3f6f6;border:1px solid #e1e4e5}.rst-content .sidebar dl,.rst-content .sidebar p,.rst-content .sidebar ul{font-size:90%}.rst-content .sidebar .last,.rst-content .sidebar>:last-child{margin-bottom:0}.rst-content .sidebar .sidebar-title{display:block;font-family:Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif;font-weight:700;background:#e1e4e5;padding:6px 12px;margin:-24px -24px 24px;font-size:100%}.rst-content .highlighted{background:#f1c40f;box-shadow:0 0 0 2px #f1c40f;display:inline;font-weight:700}.rst-content .citation-reference,.rst-content .footnote-reference{vertical-align:baseline;position:relative;top:-.4em;line-height:0;font-size:90%}.rst-content .citation-reference>span.fn-bracket,.rst-content .footnote-reference>span.fn-bracket{display:none}.rst-content .hlist{width:100%}.rst-content dl dt span.classifier:before{content:" : "}.rst-content dl dt span.classifier-delimiter{display:none!important}html.writer-html4 .rst-content table.docutils.citation,html.writer-html4 .rst-content table.docutils.footnote{background:none;border:none}html.writer-html4 .rst-content table.docutils.citation td,html.writer-html4 .rst-content table.docutils.citation tr,html.writer-html4 .rst-content table.docutils.footnote td,html.writer-html4 .rst-content table.docutils.footnote tr{border:none;background-color:transparent!important;white-space:normal}html.writer-html4 .rst-content table.docutils.citation td.label,html.writer-html4 .rst-content table.docutils.footnote td.label{padding-left:0;padding-right:0;vertical-align:top}html.writer-html5 .rst-content dl.citation,html.writer-html5 .rst-content dl.field-list,html.writer-html5 .rst-content dl.footnote{display:grid;grid-template-columns:auto minmax(80%,95%)}html.writer-html5 .rst-content dl.citation>dt,html.writer-html5 .rst-content dl.field-list>dt,html.writer-html5 .rst-content dl.footnote>dt{display:inline-grid;grid-template-columns:max-content auto}html.writer-html5 .rst-content aside.citation,html.writer-html5 .rst-content aside.footnote,html.writer-html5 .rst-content div.citation{display:grid;grid-template-columns:auto auto minmax(.65rem,auto) minmax(40%,95%)}html.writer-html5 .rst-content aside.citation>span.label,html.writer-html5 .rst-content aside.footnote>span.label,html.writer-html5 .rst-content div.citation>span.label{grid-column-start:1;grid-column-end:2}html.writer-html5 .rst-content aside.citation>span.backrefs,html.writer-html5 .rst-content aside.footnote>span.backrefs,html.writer-html5 .rst-content div.citation>span.backrefs{grid-column-start:2;grid-column-end:3;grid-row-start:1;grid-row-end:3}html.writer-html5 .rst-content aside.citation>p,html.writer-html5 .rst-content aside.footnote>p,html.writer-html5 .rst-content div.citation>p{grid-column-start:4;grid-column-end:5}html.writer-html5 .rst-content dl.citation,html.writer-html5 .rst-content dl.field-list,html.writer-html5 .rst-content dl.footnote{margin-bottom:24px}html.writer-html5 .rst-content dl.citation>dt,html.writer-html5 .rst-content dl.field-list>dt,html.writer-html5 .rst-content dl.footnote>dt{padding-left:1rem}html.writer-html5 .rst-content dl.citation>dd,html.writer-html5 .rst-content dl.citation>dt,html.writer-html5 .rst-content dl.field-list>dd,html.writer-html5 .rst-content dl.field-list>dt,html.writer-html5 .rst-content dl.footnote>dd,html.writer-html5 .rst-content dl.footnote>dt{margin-bottom:0}html.writer-html5 .rst-content dl.citation,html.writer-html5 .rst-content dl.footnote{font-size:.9rem}html.writer-html5 .rst-content dl.citation>dt,html.writer-html5 .rst-content dl.footnote>dt{margin:0 .5rem .5rem 0;line-height:1.2rem;word-break:break-all;font-weight:400}html.writer-html5 .rst-content dl.citation>dt>span.brackets:before,html.writer-html5 .rst-content dl.footnote>dt>span.brackets:before{content:"["}html.writer-html5 .rst-content dl.citation>dt>span.brackets:after,html.writer-html5 .rst-content dl.footnote>dt>span.brackets:after{content:"]"}html.writer-html5 .rst-content dl.citation>dt>span.fn-backref,html.writer-html5 .rst-content dl.footnote>dt>span.fn-backref{text-align:left;font-style:italic;margin-left:.65rem;word-break:break-word;word-spacing:-.1rem;max-width:5rem}html.writer-html5 .rst-content dl.citation>dt>span.fn-backref>a,html.writer-html5 .rst-content dl.footnote>dt>span.fn-backref>a{word-break:keep-all}html.writer-html5 .rst-content dl.citation>dt>span.fn-backref>a:not(:first-child):before,html.writer-html5 .rst-content dl.footnote>dt>span.fn-backref>a:not(:first-child):before{content:" "}html.writer-html5 .rst-content dl.citation>dd,html.writer-html5 .rst-content dl.footnote>dd{margin:0 0 .5rem;line-height:1.2rem}html.writer-html5 .rst-content dl.citation>dd p,html.writer-html5 .rst-content dl.footnote>dd p{font-size:.9rem}html.writer-html5 .rst-content aside.citation,html.writer-html5 .rst-content aside.footnote,html.writer-html5 .rst-content div.citation{padding-left:1rem;padding-right:1rem;font-size:.9rem;line-height:1.2rem}html.writer-html5 .rst-content aside.citation p,html.writer-html5 .rst-content aside.footnote p,html.writer-html5 .rst-content div.citation p{font-size:.9rem;line-height:1.2rem;margin-bottom:12px}html.writer-html5 .rst-content aside.citation span.backrefs,html.writer-html5 .rst-content aside.footnote span.backrefs,html.writer-html5 .rst-content div.citation span.backrefs{text-align:left;font-style:italic;margin-left:.65rem;word-break:break-word;word-spacing:-.1rem;max-width:5rem}html.writer-html5 .rst-content aside.citation span.backrefs>a,html.writer-html5 .rst-content aside.footnote span.backrefs>a,html.writer-html5 .rst-content div.citation span.backrefs>a{word-break:keep-all}html.writer-html5 .rst-content aside.citation span.backrefs>a:not(:first-child):before,html.writer-html5 .rst-content aside.footnote span.backrefs>a:not(:first-child):before,html.writer-html5 .rst-content div.citation span.backrefs>a:not(:first-child):before{content:" "}html.writer-html5 .rst-content aside.citation span.label,html.writer-html5 .rst-content aside.footnote span.label,html.writer-html5 .rst-content div.citation span.label{line-height:1.2rem}html.writer-html5 .rst-content aside.citation-list,html.writer-html5 .rst-content aside.footnote-list,html.writer-html5 .rst-content div.citation-list{margin-bottom:24px}html.writer-html5 .rst-content dl.option-list kbd{font-size:.9rem}.rst-content table.docutils.footnote,html.writer-html4 .rst-content table.docutils.citation,html.writer-html5 .rst-content aside.footnote,html.writer-html5 .rst-content aside.footnote-list aside.footnote,html.writer-html5 .rst-content div.citation-list>div.citation,html.writer-html5 .rst-content dl.citation,html.writer-html5 .rst-content dl.footnote{color:grey}.rst-content table.docutils.footnote code,.rst-content table.docutils.footnote tt,html.writer-html4 .rst-content table.docutils.citation code,html.writer-html4 .rst-content table.docutils.citation tt,html.writer-html5 .rst-content aside.footnote-list aside.footnote code,html.writer-html5 .rst-content aside.footnote-list aside.footnote tt,html.writer-html5 .rst-content aside.footnote code,html.writer-html5 .rst-content aside.footnote tt,html.writer-html5 .rst-content div.citation-list>div.citation code,html.writer-html5 .rst-content div.citation-list>div.citation tt,html.writer-html5 .rst-content dl.citation code,html.writer-html5 .rst-content dl.citation tt,html.writer-html5 .rst-content dl.footnote code,html.writer-html5 .rst-content dl.footnote tt{color:#555}.rst-content .wy-table-responsive.citation,.rst-content .wy-table-responsive.footnote{margin-bottom:0}.rst-content .wy-table-responsive.citation+:not(.citation),.rst-content .wy-table-responsive.footnote+:not(.footnote){margin-top:24px}.rst-content .wy-table-responsive.citation:last-child,.rst-content .wy-table-responsive.footnote:last-child{margin-bottom:24px}.rst-content table.docutils th{border-color:#e1e4e5}html.writer-html5 .rst-content table.docutils th{border:1px solid #e1e4e5}html.writer-html5 .rst-content table.docutils td>p,html.writer-html5 .rst-content table.docutils th>p{line-height:1rem;margin-bottom:0;font-size:.9rem}.rst-content table.docutils td .last,.rst-content table.docutils td .last>:last-child{margin-bottom:0}.rst-content table.field-list,.rst-content table.field-list td{border:none}.rst-content table.field-list td p{line-height:inherit}.rst-content table.field-list td>strong{display:inline-block}.rst-content table.field-list .field-name{padding-right:10px;text-align:left;white-space:nowrap}.rst-content table.field-list .field-body{text-align:left}.rst-content code,.rst-content tt{color:#000;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;padding:2px 5px}.rst-content code big,.rst-content code em,.rst-content tt big,.rst-content tt em{font-size:100%!important;line-height:normal}.rst-content code.literal,.rst-content tt.literal{color:#e74c3c;white-space:normal}.rst-content code.xref,.rst-content tt.xref,a .rst-content code,a .rst-content tt{font-weight:700;color:#404040;overflow-wrap:normal}.rst-content kbd,.rst-content pre,.rst-content samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace}.rst-content a code,.rst-content a tt{color:#2980b9}.rst-content dl{margin-bottom:24px}.rst-content dl dt{font-weight:700;margin-bottom:12px}.rst-content dl ol,.rst-content dl p,.rst-content dl table,.rst-content dl ul{margin-bottom:12px}.rst-content dl dd{margin:0 0 12px 24px;line-height:24px}.rst-content dl dd>ol:last-child,.rst-content dl dd>p:last-child,.rst-content dl dd>table:last-child,.rst-content dl dd>ul:last-child{margin-bottom:0}html.writer-html4 .rst-content dl:not(.docutils),html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple){margin-bottom:24px}html.writer-html4 .rst-content dl:not(.docutils)>dt,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt{display:table;margin:6px 0;font-size:90%;line-height:normal;background:#e7f2fa;color:#2980b9;border-top:3px solid #6ab0de;padding:6px;position:relative}html.writer-html4 .rst-content dl:not(.docutils)>dt:before,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt:before{color:#6ab0de}html.writer-html4 .rst-content dl:not(.docutils)>dt .headerlink,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt .headerlink{color:#404040;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils) dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt{margin-bottom:6px;border:none;border-left:3px solid #ccc;background:#f0f0f0;color:#555}html.writer-html4 .rst-content dl:not(.docutils) dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt .headerlink,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt .headerlink{color:#404040;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils)>dt:first-child,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt:first-child{margin-top:0}html.writer-html4 .rst-content dl:not(.docutils) code.descclassname,html.writer-html4 .rst-content dl:not(.docutils) code.descname,html.writer-html4 .rst-content dl:not(.docutils) tt.descclassname,html.writer-html4 .rst-content dl:not(.docutils) tt.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) code.descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) code.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) tt.descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) tt.descname{background-color:transparent;border:none;padding:0;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils) code.descname,html.writer-html4 .rst-content dl:not(.docutils) tt.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) code.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) tt.descname{font-weight:700}html.writer-html4 .rst-content dl:not(.docutils) .optional,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .optional{display:inline-block;padding:0 4px;color:#000;font-weight:700}html.writer-html4 .rst-content dl:not(.docutils) .property,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .property{display:inline-block;padding-right:8px;max-width:100%}html.writer-html4 .rst-content dl:not(.docutils) .k,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .k{font-style:italic}html.writer-html4 .rst-content dl:not(.docutils) .descclassname,html.writer-html4 .rst-content dl:not(.docutils) .descname,html.writer-html4 .rst-content dl:not(.docutils) .sig-name,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .sig-name{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;color:#000}.rst-content .viewcode-back,.rst-content .viewcode-link{display:inline-block;color:#27ae60;font-size:80%;padding-left:24px}.rst-content .viewcode-back{display:block;float:right}.rst-content p.rubric{margin-bottom:12px;font-weight:700}.rst-content code.download,.rst-content tt.download{background:inherit;padding:inherit;font-weight:400;font-family:inherit;font-size:inherit;color:inherit;border:inherit;white-space:inherit}.rst-content code.download span:first-child,.rst-content tt.download span:first-child{-webkit-font-smoothing:subpixel-antialiased}.rst-content code.download span:first-child:before,.rst-content tt.download span:first-child:before{margin-right:4px}.rst-content .guilabel{border:1px solid #7fbbe3;background:#e7f2fa;font-size:80%;font-weight:700;border-radius:4px;padding:2.4px 6px;margin:auto 2px}.rst-content :not(dl.option-list)>:not(dt):not(kbd):not(.kbd)>.kbd,.rst-content :not(dl.option-list)>:not(dt):not(kbd):not(.kbd)>kbd{color:inherit;font-size:80%;background-color:#fff;border:1px solid #a6a6a6;border-radius:4px;box-shadow:0 2px grey;padding:2.4px 6px;margin:auto 0}.rst-content .versionmodified{font-style:italic}@media screen and (max-width:480px){.rst-content .sidebar{width:100%}}span[id*=MathJax-Span]{color:#404040}.math{text-align:center}@font-face{font-family:Lato;src:url(fonts/lato-normal.woff2?bd03a2cc277bbbc338d464e679fe9942) format("woff2"),url(fonts/lato-normal.woff?27bd77b9162d388cb8d4c4217c7c5e2a) format("woff");font-weight:400;font-style:normal;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-bold.woff2?cccb897485813c7c256901dbca54ecf2) format("woff2"),url(fonts/lato-bold.woff?d878b6c29b10beca227e9eef4246111b) format("woff");font-weight:700;font-style:normal;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-bold-italic.woff2?0b6bb6725576b072c5d0b02ecdd1900d) format("woff2"),url(fonts/lato-bold-italic.woff?9c7e4e9eb485b4a121c760e61bc3707c) format("woff");font-weight:700;font-style:italic;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-normal-italic.woff2?4eb103b4d12be57cb1d040ed5e162e9d) format("woff2"),url(fonts/lato-normal-italic.woff?f28f2d6482446544ef1ea1ccc6dd5892) format("woff");font-weight:400;font-style:italic;font-display:block}@font-face{font-family:Roboto Slab;font-style:normal;font-weight:400;src:url(fonts/Roboto-Slab-Regular.woff2?7abf5b8d04d26a2cafea937019bca958) format("woff2"),url(fonts/Roboto-Slab-Regular.woff?c1be9284088d487c5e3ff0a10a92e58c) format("woff");font-display:block}@font-face{font-family:Roboto Slab;font-style:normal;font-weight:700;src:url(fonts/Roboto-Slab-Bold.woff2?9984f4a9bda09be08e83f2506954adbe) format("woff2"),url(fonts/Roboto-Slab-Bold.woff?bed5564a116b05148e3b3bea6fb1162a) format("woff");font-display:block} \ No newline at end of file diff --git a/docs/html/_static/doctools.js b/docs/html/_static/doctools.js new file mode 100644 index 0000000..d06a71d --- /dev/null +++ b/docs/html/_static/doctools.js @@ -0,0 +1,156 @@ +/* + * doctools.js + * ~~~~~~~~~~~ + * + * Base JavaScript utilities for all Sphinx HTML documentation. + * + * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ +"use strict"; + +const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([ + "TEXTAREA", + "INPUT", + "SELECT", + "BUTTON", +]); + +const _ready = (callback) => { + if (document.readyState !== "loading") { + callback(); + } else { + document.addEventListener("DOMContentLoaded", callback); + } +}; + +/** + * Small JavaScript module for the documentation. + */ +const Documentation = { + init: () => { + Documentation.initDomainIndexTable(); + Documentation.initOnKeyListeners(); + }, + + /** + * i18n support + */ + TRANSLATIONS: {}, + PLURAL_EXPR: (n) => (n === 1 ? 0 : 1), + LOCALE: "unknown", + + // gettext and ngettext don't access this so that the functions + // can safely bound to a different name (_ = Documentation.gettext) + gettext: (string) => { + const translated = Documentation.TRANSLATIONS[string]; + switch (typeof translated) { + case "undefined": + return string; // no translation + case "string": + return translated; // translation exists + default: + return translated[0]; // (singular, plural) translation tuple exists + } + }, + + ngettext: (singular, plural, n) => { + const translated = Documentation.TRANSLATIONS[singular]; + if (typeof translated !== "undefined") + return translated[Documentation.PLURAL_EXPR(n)]; + return n === 1 ? singular : plural; + }, + + addTranslations: (catalog) => { + Object.assign(Documentation.TRANSLATIONS, catalog.messages); + Documentation.PLURAL_EXPR = new Function( + "n", + `return (${catalog.plural_expr})` + ); + Documentation.LOCALE = catalog.locale; + }, + + /** + * helper function to focus on search bar + */ + focusSearchBar: () => { + document.querySelectorAll("input[name=q]")[0]?.focus(); + }, + + /** + * Initialise the domain index toggle buttons + */ + initDomainIndexTable: () => { + const toggler = (el) => { + const idNumber = el.id.substr(7); + const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`); + if (el.src.substr(-9) === "minus.png") { + el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`; + toggledRows.forEach((el) => (el.style.display = "none")); + } else { + el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`; + toggledRows.forEach((el) => (el.style.display = "")); + } + }; + + const togglerElements = document.querySelectorAll("img.toggler"); + togglerElements.forEach((el) => + el.addEventListener("click", (event) => toggler(event.currentTarget)) + ); + togglerElements.forEach((el) => (el.style.display = "")); + if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler); + }, + + initOnKeyListeners: () => { + // only install a listener if it is really needed + if ( + !DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS && + !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS + ) + return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.altKey || event.ctrlKey || event.metaKey) return; + + if (!event.shiftKey) { + switch (event.key) { + case "ArrowLeft": + if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; + + const prevLink = document.querySelector('link[rel="prev"]'); + if (prevLink && prevLink.href) { + window.location.href = prevLink.href; + event.preventDefault(); + } + break; + case "ArrowRight": + if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; + + const nextLink = document.querySelector('link[rel="next"]'); + if (nextLink && nextLink.href) { + window.location.href = nextLink.href; + event.preventDefault(); + } + break; + } + } + + // some keyboard layouts may need Shift to get / + switch (event.key) { + case "/": + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break; + Documentation.focusSearchBar(); + event.preventDefault(); + } + }); + }, +}; + +// quick alias for translations +const _ = Documentation.gettext; + +_ready(Documentation.init); diff --git a/docs/html/_static/documentation_options.js b/docs/html/_static/documentation_options.js new file mode 100644 index 0000000..b57ae3b --- /dev/null +++ b/docs/html/_static/documentation_options.js @@ -0,0 +1,14 @@ +var DOCUMENTATION_OPTIONS = { + URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), + VERSION: '', + LANGUAGE: 'en', + COLLAPSE_INDEX: false, + BUILDER: 'html', + FILE_SUFFIX: '.html', + LINK_SUFFIX: '.html', + HAS_SOURCE: true, + SOURCELINK_SUFFIX: '.txt', + NAVIGATION_WITH_KEYS: false, + SHOW_SEARCH_SUMMARY: true, + ENABLE_SEARCH_SHORTCUTS: true, +}; \ No newline at end of file diff --git a/docs/html/_static/file.png b/docs/html/_static/file.png new file mode 100644 index 0000000..a858a41 Binary files /dev/null and b/docs/html/_static/file.png differ diff --git a/docs/html/_static/js/badge_only.js b/docs/html/_static/js/badge_only.js new file mode 100644 index 0000000..526d723 --- /dev/null +++ b/docs/html/_static/js/badge_only.js @@ -0,0 +1 @@ +!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}}); \ No newline at end of file diff --git a/docs/html/_static/js/html5shiv-printshiv.min.js b/docs/html/_static/js/html5shiv-printshiv.min.js new file mode 100644 index 0000000..2b43bd0 --- /dev/null +++ b/docs/html/_static/js/html5shiv-printshiv.min.js @@ -0,0 +1,4 @@ +/** +* @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document); \ No newline at end of file diff --git a/docs/html/_static/js/html5shiv.min.js b/docs/html/_static/js/html5shiv.min.js new file mode 100644 index 0000000..cd1c674 --- /dev/null +++ b/docs/html/_static/js/html5shiv.min.js @@ -0,0 +1,4 @@ +/** +* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); \ No newline at end of file diff --git a/docs/html/_static/js/theme.js b/docs/html/_static/js/theme.js new file mode 100644 index 0000000..1fddb6e --- /dev/null +++ b/docs/html/_static/js/theme.js @@ -0,0 +1 @@ +!function(n){var e={};function t(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,i){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:i})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(i,o,function(e){return n[e]}.bind(null,o));return i},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){t(1),n.exports=t(3)},function(n,e,t){(function(){var e="undefined"!=typeof window?window.jQuery:t(2);n.exports.ThemeNav={navBar:null,win:null,winScroll:!1,winResize:!1,linkScroll:!1,winPosition:0,winHeight:null,docHeight:null,isRunning:!1,enable:function(n){var t=this;void 0===n&&(n=!0),t.isRunning||(t.isRunning=!0,e((function(e){t.init(e),t.reset(),t.win.on("hashchange",t.reset),n&&t.win.on("scroll",(function(){t.linkScroll||t.winScroll||(t.winScroll=!0,requestAnimationFrame((function(){t.onScroll()})))})),t.win.on("resize",(function(){t.winResize||(t.winResize=!0,requestAnimationFrame((function(){t.onResize()})))})),t.onResize()})))},enableSticky:function(){this.enable(!0)},init:function(n){n(document);var e=this;this.navBar=n("div.wy-side-scroll:first"),this.win=n(window),n(document).on("click","[data-toggle='wy-nav-top']",(function(){n("[data-toggle='wy-nav-shift']").toggleClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift")})).on("click",".wy-menu-vertical .current ul li a",(function(){var t=n(this);n("[data-toggle='wy-nav-shift']").removeClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift"),e.toggleCurrent(t),e.hashChange()})).on("click","[data-toggle='rst-current-version']",(function(){n("[data-toggle='rst-versions']").toggleClass("shift-up")})),n("table.docutils:not(.field-list,.footnote,.citation)").wrap("
"),n("table.docutils.footnote").wrap("
"),n("table.docutils.citation").wrap("
"),n(".wy-menu-vertical ul").not(".simple").siblings("a").each((function(){var t=n(this);expand=n(''),expand.on("click",(function(n){return e.toggleCurrent(t),n.stopPropagation(),!1})),t.prepend(expand)}))},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),t=e.find('[href="'+n+'"]');if(0===t.length){var i=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(t=e.find('[href="#'+i.attr("id")+'"]')).length&&(t=e.find('[href="#"]'))}if(t.length>0){$(".wy-menu-vertical .current").removeClass("current").attr("aria-expanded","false"),t.addClass("current").attr("aria-expanded","true"),t.closest("li.toctree-l1").parent().addClass("current").attr("aria-expanded","true");for(let n=1;n<=10;n++)t.closest("li.toctree-l"+n).addClass("current").attr("aria-expanded","true");t[0].scrollIntoView()}}catch(n){console.log("Error expanding nav for anchor",n)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,t=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(t),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",(function(){this.linkScroll=!1}))},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current").attr("aria-expanded","false"),e.siblings().find("li.current").removeClass("current").attr("aria-expanded","false");var t=e.find("> ul li");t.length&&(t.removeClass("current").attr("aria-expanded","false"),e.toggleClass("current").attr("aria-expanded",(function(n,e){return"true"==e?"false":"true"})))}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:n.exports.ThemeNav,StickyNav:n.exports.ThemeNav}),function(){for(var n=0,e=["ms","moz","webkit","o"],t=0;t0 + var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 + var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 + var s_v = "^(" + C + ")?" + v; // vowel in stem + + this.stemWord = function (w) { + var stem; + var suffix; + var firstch; + var origword = w; + + if (w.length < 3) + return w; + + var re; + var re2; + var re3; + var re4; + + firstch = w.substr(0,1); + if (firstch == "y") + w = firstch.toUpperCase() + w.substr(1); + + // Step 1a + re = /^(.+?)(ss|i)es$/; + re2 = /^(.+?)([^s])s$/; + + if (re.test(w)) + w = w.replace(re,"$1$2"); + else if (re2.test(w)) + w = w.replace(re2,"$1$2"); + + // Step 1b + re = /^(.+?)eed$/; + re2 = /^(.+?)(ed|ing)$/; + if (re.test(w)) { + var fp = re.exec(w); + re = new RegExp(mgr0); + if (re.test(fp[1])) { + re = /.$/; + w = w.replace(re,""); + } + } + else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = new RegExp(s_v); + if (re2.test(stem)) { + w = stem; + re2 = /(at|bl|iz)$/; + re3 = new RegExp("([^aeiouylsz])\\1$"); + re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re2.test(w)) + w = w + "e"; + else if (re3.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + else if (re4.test(w)) + w = w + "e"; + } + } + + // Step 1c + re = /^(.+?)y$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(s_v); + if (re.test(stem)) + w = stem + "i"; + } + + // Step 2 + re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) + w = stem + step2list[suffix]; + } + + // Step 3 + re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) + w = stem + step3list[suffix]; + } + + // Step 4 + re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + re2 = /^(.+?)(s|t)(ion)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + if (re.test(stem)) + w = stem; + } + else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = new RegExp(mgr1); + if (re2.test(stem)) + w = stem; + } + + // Step 5 + re = /^(.+?)e$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + re2 = new RegExp(meq1); + re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) + w = stem; + } + re = /ll$/; + re2 = new RegExp(mgr1); + if (re.test(w) && re2.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + + // and turn initial Y back to y + if (firstch == "y") + w = firstch.toLowerCase() + w.substr(1); + return w; + } +} + diff --git a/docs/html/_static/minus.png b/docs/html/_static/minus.png new file mode 100644 index 0000000..d96755f Binary files /dev/null and b/docs/html/_static/minus.png differ diff --git a/docs/html/_static/plus.png b/docs/html/_static/plus.png new file mode 100644 index 0000000..7107cec Binary files /dev/null and b/docs/html/_static/plus.png differ diff --git a/docs/html/_static/pygments.css b/docs/html/_static/pygments.css new file mode 100644 index 0000000..08bec68 --- /dev/null +++ b/docs/html/_static/pygments.css @@ -0,0 +1,74 @@ +pre { line-height: 125%; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +.highlight .hll { background-color: #ffffcc } +.highlight { background: #f8f8f8; } +.highlight .c { color: #3D7B7B; font-style: italic } /* Comment */ +.highlight .err { border: 1px solid #FF0000 } /* Error */ +.highlight .k { color: #008000; font-weight: bold } /* Keyword */ +.highlight .o { color: #666666 } /* Operator */ +.highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ +.highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #9C6500 } /* Comment.Preproc */ +.highlight .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ +.highlight .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #A00000 } /* Generic.Deleted */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #E40000 } /* Generic.Error */ +.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.highlight .gi { color: #008400 } /* Generic.Inserted */ +.highlight .go { color: #717171 } /* Generic.Output */ +.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.highlight .gt { color: #0044DD } /* Generic.Traceback */ +.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { color: #008000 } /* Keyword.Pseudo */ +.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #B00040 } /* Keyword.Type */ +.highlight .m { color: #666666 } /* Literal.Number */ +.highlight .s { color: #BA2121 } /* Literal.String */ +.highlight .na { color: #687822 } /* Name.Attribute */ +.highlight .nb { color: #008000 } /* Name.Builtin */ +.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ +.highlight .no { color: #880000 } /* Name.Constant */ +.highlight .nd { color: #AA22FF } /* Name.Decorator */ +.highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */ +.highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #0000FF } /* Name.Function */ +.highlight .nl { color: #767600 } /* Name.Label */ +.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ +.highlight .nv { color: #19177C } /* Name.Variable */ +.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mb { color: #666666 } /* Literal.Number.Bin */ +.highlight .mf { color: #666666 } /* Literal.Number.Float */ +.highlight .mh { color: #666666 } /* Literal.Number.Hex */ +.highlight .mi { color: #666666 } /* Literal.Number.Integer */ +.highlight .mo { color: #666666 } /* Literal.Number.Oct */ +.highlight .sa { color: #BA2121 } /* Literal.String.Affix */ +.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ +.highlight .sc { color: #BA2121 } /* Literal.String.Char */ +.highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */ +.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ +.highlight .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ +.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ +.highlight .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ +.highlight .sx { color: #008000 } /* Literal.String.Other */ +.highlight .sr { color: #A45A77 } /* Literal.String.Regex */ +.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ +.highlight .ss { color: #19177C } /* Literal.String.Symbol */ +.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ +.highlight .fm { color: #0000FF } /* Name.Function.Magic */ +.highlight .vc { color: #19177C } /* Name.Variable.Class */ +.highlight .vg { color: #19177C } /* Name.Variable.Global */ +.highlight .vi { color: #19177C } /* Name.Variable.Instance */ +.highlight .vm { color: #19177C } /* Name.Variable.Magic */ +.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/docs/html/_static/searchtools.js b/docs/html/_static/searchtools.js new file mode 100644 index 0000000..97d56a7 --- /dev/null +++ b/docs/html/_static/searchtools.js @@ -0,0 +1,566 @@ +/* + * searchtools.js + * ~~~~~~~~~~~~~~~~ + * + * Sphinx JavaScript utilities for the full-text search. + * + * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ +"use strict"; + +/** + * Simple result scoring code. + */ +if (typeof Scorer === "undefined") { + var Scorer = { + // Implement the following function to further tweak the score for each result + // The function takes a result array [docname, title, anchor, descr, score, filename] + // and returns the new score. + /* + score: result => { + const [docname, title, anchor, descr, score, filename] = result + return score + }, + */ + + // query matches the full name of an object + objNameMatch: 11, + // or matches in the last dotted part of the object name + objPartialMatch: 6, + // Additive scores depending on the priority of the object + objPrio: { + 0: 15, // used to be importantResults + 1: 5, // used to be objectResults + 2: -5, // used to be unimportantResults + }, + // Used when the priority is not in the mapping. + objPrioDefault: 0, + + // query found in title + title: 15, + partialTitle: 7, + // query found in terms + term: 5, + partialTerm: 2, + }; +} + +const _removeChildren = (element) => { + while (element && element.lastChild) element.removeChild(element.lastChild); +}; + +/** + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping + */ +const _escapeRegExp = (string) => + string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string + +const _displayItem = (item, searchTerms) => { + const docBuilder = DOCUMENTATION_OPTIONS.BUILDER; + const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT; + const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; + const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; + const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; + + const [docName, title, anchor, descr, score, _filename] = item; + + let listItem = document.createElement("li"); + let requestUrl; + let linkUrl; + if (docBuilder === "dirhtml") { + // dirhtml builder + let dirname = docName + "/"; + if (dirname.match(/\/index\/$/)) + dirname = dirname.substring(0, dirname.length - 6); + else if (dirname === "index/") dirname = ""; + requestUrl = docUrlRoot + dirname; + linkUrl = requestUrl; + } else { + // normal html builders + requestUrl = docUrlRoot + docName + docFileSuffix; + linkUrl = docName + docLinkSuffix; + } + let linkEl = listItem.appendChild(document.createElement("a")); + linkEl.href = linkUrl + anchor; + linkEl.dataset.score = score; + linkEl.innerHTML = title; + if (descr) + listItem.appendChild(document.createElement("span")).innerHTML = + " (" + descr + ")"; + else if (showSearchSummary) + fetch(requestUrl) + .then((responseData) => responseData.text()) + .then((data) => { + if (data) + listItem.appendChild( + Search.makeSearchSummary(data, searchTerms) + ); + }); + Search.output.appendChild(listItem); +}; +const _finishSearch = (resultCount) => { + Search.stopPulse(); + Search.title.innerText = _("Search Results"); + if (!resultCount) + Search.status.innerText = Documentation.gettext( + "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories." + ); + else + Search.status.innerText = _( + `Search finished, found ${resultCount} page(s) matching the search query.` + ); +}; +const _displayNextItem = ( + results, + resultCount, + searchTerms +) => { + // results left, load the summary and display it + // this is intended to be dynamic (don't sub resultsCount) + if (results.length) { + _displayItem(results.pop(), searchTerms); + setTimeout( + () => _displayNextItem(results, resultCount, searchTerms), + 5 + ); + } + // search finished, update title and status message + else _finishSearch(resultCount); +}; + +/** + * Default splitQuery function. Can be overridden in ``sphinx.search`` with a + * custom function per language. + * + * The regular expression works by splitting the string on consecutive characters + * that are not Unicode letters, numbers, underscores, or emoji characters. + * This is the same as ``\W+`` in Python, preserving the surrogate pair area. + */ +if (typeof splitQuery === "undefined") { + var splitQuery = (query) => query + .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}]+/gu) + .filter(term => term) // remove remaining empty strings +} + +/** + * Search Module + */ +const Search = { + _index: null, + _queued_query: null, + _pulse_status: -1, + + htmlToText: (htmlString) => { + const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html'); + htmlElement.querySelectorAll(".headerlink").forEach((el) => { el.remove() }); + const docContent = htmlElement.querySelector('[role="main"]'); + if (docContent !== undefined) return docContent.textContent; + console.warn( + "Content block not found. Sphinx search tries to obtain it via '[role=main]'. Could you check your theme or template." + ); + return ""; + }, + + init: () => { + const query = new URLSearchParams(window.location.search).get("q"); + document + .querySelectorAll('input[name="q"]') + .forEach((el) => (el.value = query)); + if (query) Search.performSearch(query); + }, + + loadIndex: (url) => + (document.body.appendChild(document.createElement("script")).src = url), + + setIndex: (index) => { + Search._index = index; + if (Search._queued_query !== null) { + const query = Search._queued_query; + Search._queued_query = null; + Search.query(query); + } + }, + + hasIndex: () => Search._index !== null, + + deferQuery: (query) => (Search._queued_query = query), + + stopPulse: () => (Search._pulse_status = -1), + + startPulse: () => { + if (Search._pulse_status >= 0) return; + + const pulse = () => { + Search._pulse_status = (Search._pulse_status + 1) % 4; + Search.dots.innerText = ".".repeat(Search._pulse_status); + if (Search._pulse_status >= 0) window.setTimeout(pulse, 500); + }; + pulse(); + }, + + /** + * perform a search for something (or wait until index is loaded) + */ + performSearch: (query) => { + // create the required interface elements + const searchText = document.createElement("h2"); + searchText.textContent = _("Searching"); + const searchSummary = document.createElement("p"); + searchSummary.classList.add("search-summary"); + searchSummary.innerText = ""; + const searchList = document.createElement("ul"); + searchList.classList.add("search"); + + const out = document.getElementById("search-results"); + Search.title = out.appendChild(searchText); + Search.dots = Search.title.appendChild(document.createElement("span")); + Search.status = out.appendChild(searchSummary); + Search.output = out.appendChild(searchList); + + const searchProgress = document.getElementById("search-progress"); + // Some themes don't use the search progress node + if (searchProgress) { + searchProgress.innerText = _("Preparing search..."); + } + Search.startPulse(); + + // index already loaded, the browser was quick! + if (Search.hasIndex()) Search.query(query); + else Search.deferQuery(query); + }, + + /** + * execute search (requires search index to be loaded) + */ + query: (query) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const titles = Search._index.titles; + const allTitles = Search._index.alltitles; + const indexEntries = Search._index.indexentries; + + // stem the search terms and add them to the correct list + const stemmer = new Stemmer(); + const searchTerms = new Set(); + const excludedTerms = new Set(); + const highlightTerms = new Set(); + const objectTerms = new Set(splitQuery(query.toLowerCase().trim())); + splitQuery(query.trim()).forEach((queryTerm) => { + const queryTermLower = queryTerm.toLowerCase(); + + // maybe skip this "word" + // stopwords array is from language_data.js + if ( + stopwords.indexOf(queryTermLower) !== -1 || + queryTerm.match(/^\d+$/) + ) + return; + + // stem the word + let word = stemmer.stemWord(queryTermLower); + // select the correct list + if (word[0] === "-") excludedTerms.add(word.substr(1)); + else { + searchTerms.add(word); + highlightTerms.add(queryTermLower); + } + }); + + if (SPHINX_HIGHLIGHT_ENABLED) { // set in sphinx_highlight.js + localStorage.setItem("sphinx_highlight_terms", [...highlightTerms].join(" ")) + } + + // console.debug("SEARCH: searching for:"); + // console.info("required: ", [...searchTerms]); + // console.info("excluded: ", [...excludedTerms]); + + // array of [docname, title, anchor, descr, score, filename] + let results = []; + _removeChildren(document.getElementById("search-progress")); + + const queryLower = query.toLowerCase(); + for (const [title, foundTitles] of Object.entries(allTitles)) { + if (title.toLowerCase().includes(queryLower) && (queryLower.length >= title.length/2)) { + for (const [file, id] of foundTitles) { + let score = Math.round(100 * queryLower.length / title.length) + results.push([ + docNames[file], + titles[file] !== title ? `${titles[file]} > ${title}` : title, + id !== null ? "#" + id : "", + null, + score, + filenames[file], + ]); + } + } + } + + // search for explicit entries in index directives + for (const [entry, foundEntries] of Object.entries(indexEntries)) { + if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) { + for (const [file, id] of foundEntries) { + let score = Math.round(100 * queryLower.length / entry.length) + results.push([ + docNames[file], + titles[file], + id ? "#" + id : "", + null, + score, + filenames[file], + ]); + } + } + } + + // lookup as object + objectTerms.forEach((term) => + results.push(...Search.performObjectSearch(term, objectTerms)) + ); + + // lookup as search terms in fulltext + results.push(...Search.performTermsSearch(searchTerms, excludedTerms)); + + // let the scorer override scores with a custom scoring function + if (Scorer.score) results.forEach((item) => (item[4] = Scorer.score(item))); + + // now sort the results by score (in opposite order of appearance, since the + // display function below uses pop() to retrieve items) and then + // alphabetically + results.sort((a, b) => { + const leftScore = a[4]; + const rightScore = b[4]; + if (leftScore === rightScore) { + // same score: sort alphabetically + const leftTitle = a[1].toLowerCase(); + const rightTitle = b[1].toLowerCase(); + if (leftTitle === rightTitle) return 0; + return leftTitle > rightTitle ? -1 : 1; // inverted is intentional + } + return leftScore > rightScore ? 1 : -1; + }); + + // remove duplicate search results + // note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept + let seen = new Set(); + results = results.reverse().reduce((acc, result) => { + let resultStr = result.slice(0, 4).concat([result[5]]).map(v => String(v)).join(','); + if (!seen.has(resultStr)) { + acc.push(result); + seen.add(resultStr); + } + return acc; + }, []); + + results = results.reverse(); + + // for debugging + //Search.lastresults = results.slice(); // a copy + // console.info("search results:", Search.lastresults); + + // print the results + _displayNextItem(results, results.length, searchTerms); + }, + + /** + * search for object names + */ + performObjectSearch: (object, objectTerms) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const objects = Search._index.objects; + const objNames = Search._index.objnames; + const titles = Search._index.titles; + + const results = []; + + const objectSearchCallback = (prefix, match) => { + const name = match[4] + const fullname = (prefix ? prefix + "." : "") + name; + const fullnameLower = fullname.toLowerCase(); + if (fullnameLower.indexOf(object) < 0) return; + + let score = 0; + const parts = fullnameLower.split("."); + + // check for different match types: exact matches of full name or + // "last name" (i.e. last dotted part) + if (fullnameLower === object || parts.slice(-1)[0] === object) + score += Scorer.objNameMatch; + else if (parts.slice(-1)[0].indexOf(object) > -1) + score += Scorer.objPartialMatch; // matches in last name + + const objName = objNames[match[1]][2]; + const title = titles[match[0]]; + + // If more than one term searched for, we require other words to be + // found in the name/title/description + const otherTerms = new Set(objectTerms); + otherTerms.delete(object); + if (otherTerms.size > 0) { + const haystack = `${prefix} ${name} ${objName} ${title}`.toLowerCase(); + if ( + [...otherTerms].some((otherTerm) => haystack.indexOf(otherTerm) < 0) + ) + return; + } + + let anchor = match[3]; + if (anchor === "") anchor = fullname; + else if (anchor === "-") anchor = objNames[match[1]][1] + "-" + fullname; + + const descr = objName + _(", in ") + title; + + // add custom score for some objects according to scorer + if (Scorer.objPrio.hasOwnProperty(match[2])) + score += Scorer.objPrio[match[2]]; + else score += Scorer.objPrioDefault; + + results.push([ + docNames[match[0]], + fullname, + "#" + anchor, + descr, + score, + filenames[match[0]], + ]); + }; + Object.keys(objects).forEach((prefix) => + objects[prefix].forEach((array) => + objectSearchCallback(prefix, array) + ) + ); + return results; + }, + + /** + * search for full-text terms in the index + */ + performTermsSearch: (searchTerms, excludedTerms) => { + // prepare search + const terms = Search._index.terms; + const titleTerms = Search._index.titleterms; + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const titles = Search._index.titles; + + const scoreMap = new Map(); + const fileMap = new Map(); + + // perform the search on the required terms + searchTerms.forEach((word) => { + const files = []; + const arr = [ + { files: terms[word], score: Scorer.term }, + { files: titleTerms[word], score: Scorer.title }, + ]; + // add support for partial matches + if (word.length > 2) { + const escapedWord = _escapeRegExp(word); + Object.keys(terms).forEach((term) => { + if (term.match(escapedWord) && !terms[word]) + arr.push({ files: terms[term], score: Scorer.partialTerm }); + }); + Object.keys(titleTerms).forEach((term) => { + if (term.match(escapedWord) && !titleTerms[word]) + arr.push({ files: titleTerms[word], score: Scorer.partialTitle }); + }); + } + + // no match but word was a required one + if (arr.every((record) => record.files === undefined)) return; + + // found search word in contents + arr.forEach((record) => { + if (record.files === undefined) return; + + let recordFiles = record.files; + if (recordFiles.length === undefined) recordFiles = [recordFiles]; + files.push(...recordFiles); + + // set score for the word in each file + recordFiles.forEach((file) => { + if (!scoreMap.has(file)) scoreMap.set(file, {}); + scoreMap.get(file)[word] = record.score; + }); + }); + + // create the mapping + files.forEach((file) => { + if (fileMap.has(file) && fileMap.get(file).indexOf(word) === -1) + fileMap.get(file).push(word); + else fileMap.set(file, [word]); + }); + }); + + // now check if the files don't contain excluded terms + const results = []; + for (const [file, wordList] of fileMap) { + // check if all requirements are matched + + // as search terms with length < 3 are discarded + const filteredTermCount = [...searchTerms].filter( + (term) => term.length > 2 + ).length; + if ( + wordList.length !== searchTerms.size && + wordList.length !== filteredTermCount + ) + continue; + + // ensure that none of the excluded terms is in the search result + if ( + [...excludedTerms].some( + (term) => + terms[term] === file || + titleTerms[term] === file || + (terms[term] || []).includes(file) || + (titleTerms[term] || []).includes(file) + ) + ) + break; + + // select one (max) score for the file. + const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w])); + // add result to the result list + results.push([ + docNames[file], + titles[file], + "", + null, + score, + filenames[file], + ]); + } + return results; + }, + + /** + * helper function to return a node containing the + * search summary for a given text. keywords is a list + * of stemmed words. + */ + makeSearchSummary: (htmlText, keywords) => { + const text = Search.htmlToText(htmlText); + if (text === "") return null; + + const textLower = text.toLowerCase(); + const actualStartPosition = [...keywords] + .map((k) => textLower.indexOf(k.toLowerCase())) + .filter((i) => i > -1) + .slice(-1)[0]; + const startWithContext = Math.max(actualStartPosition - 120, 0); + + const top = startWithContext === 0 ? "" : "..."; + const tail = startWithContext + 240 < text.length ? "..." : ""; + + let summary = document.createElement("p"); + summary.classList.add("context"); + summary.textContent = top + text.substr(startWithContext, 240).trim() + tail; + + return summary; + }, +}; + +_ready(Search.init); diff --git a/docs/html/_static/sphinx_highlight.js b/docs/html/_static/sphinx_highlight.js new file mode 100644 index 0000000..aae669d --- /dev/null +++ b/docs/html/_static/sphinx_highlight.js @@ -0,0 +1,144 @@ +/* Highlighting utilities for Sphinx HTML documentation. */ +"use strict"; + +const SPHINX_HIGHLIGHT_ENABLED = true + +/** + * highlight a given string on a node by wrapping it in + * span elements with the given class name. + */ +const _highlight = (node, addItems, text, className) => { + if (node.nodeType === Node.TEXT_NODE) { + const val = node.nodeValue; + const parent = node.parentNode; + const pos = val.toLowerCase().indexOf(text); + if ( + pos >= 0 && + !parent.classList.contains(className) && + !parent.classList.contains("nohighlight") + ) { + let span; + + const closestNode = parent.closest("body, svg, foreignObject"); + const isInSVG = closestNode && closestNode.matches("svg"); + if (isInSVG) { + span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + } else { + span = document.createElement("span"); + span.classList.add(className); + } + + span.appendChild(document.createTextNode(val.substr(pos, text.length))); + parent.insertBefore( + span, + parent.insertBefore( + document.createTextNode(val.substr(pos + text.length)), + node.nextSibling + ) + ); + node.nodeValue = val.substr(0, pos); + + if (isInSVG) { + const rect = document.createElementNS( + "http://www.w3.org/2000/svg", + "rect" + ); + const bbox = parent.getBBox(); + rect.x.baseVal.value = bbox.x; + rect.y.baseVal.value = bbox.y; + rect.width.baseVal.value = bbox.width; + rect.height.baseVal.value = bbox.height; + rect.setAttribute("class", className); + addItems.push({ parent: parent, target: rect }); + } + } + } else if (node.matches && !node.matches("button, select, textarea")) { + node.childNodes.forEach((el) => _highlight(el, addItems, text, className)); + } +}; +const _highlightText = (thisNode, text, className) => { + let addItems = []; + _highlight(thisNode, addItems, text, className); + addItems.forEach((obj) => + obj.parent.insertAdjacentElement("beforebegin", obj.target) + ); +}; + +/** + * Small JavaScript module for the documentation. + */ +const SphinxHighlight = { + + /** + * highlight the search words provided in localstorage in the text + */ + highlightSearchWords: () => { + if (!SPHINX_HIGHLIGHT_ENABLED) return; // bail if no highlight + + // get and clear terms from localstorage + const url = new URL(window.location); + const highlight = + localStorage.getItem("sphinx_highlight_terms") + || url.searchParams.get("highlight") + || ""; + localStorage.removeItem("sphinx_highlight_terms") + url.searchParams.delete("highlight"); + window.history.replaceState({}, "", url); + + // get individual terms from highlight string + const terms = highlight.toLowerCase().split(/\s+/).filter(x => x); + if (terms.length === 0) return; // nothing to do + + // There should never be more than one element matching "div.body" + const divBody = document.querySelectorAll("div.body"); + const body = divBody.length ? divBody[0] : document.querySelector("body"); + window.setTimeout(() => { + terms.forEach((term) => _highlightText(body, term, "highlighted")); + }, 10); + + const searchBox = document.getElementById("searchbox"); + if (searchBox === null) return; + searchBox.appendChild( + document + .createRange() + .createContextualFragment( + '" + ) + ); + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords: () => { + document + .querySelectorAll("#searchbox .highlight-link") + .forEach((el) => el.remove()); + document + .querySelectorAll("span.highlighted") + .forEach((el) => el.classList.remove("highlighted")); + localStorage.removeItem("sphinx_highlight_terms") + }, + + initEscapeListener: () => { + // only install a listener if it is really needed + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return; + if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) { + SphinxHighlight.hideSearchWords(); + event.preventDefault(); + } + }); + }, +}; + +_ready(SphinxHighlight.highlightSearchWords); +_ready(SphinxHighlight.initEscapeListener); diff --git a/docs/html/api/Lib.Allocator.html b/docs/html/api/Lib.Allocator.html new file mode 100644 index 0000000..7dfcdf7 --- /dev/null +++ b/docs/html/api/Lib.Allocator.html @@ -0,0 +1,187 @@ + + + + + + + Lib.Allocator module — MiniC documentation + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Lib.Allocator module

+

This file defines the base class Allocator +and the naïve implementation NaiveAllocator.

+
+
+class Lib.Allocator.Allocator(fdata: FunctionData)[source]
+

Bases: object

+

General base class for Naive, AllInMem and Smart Allocators. +Replace all temporaries in the code with actual data locations.

+

Allocation is done in two steps:

+
    +
  • First, prepare() is responsible for calling +Lib.Operands.TemporaryPool.set_temp_allocation() +with a mapping from temporaries to where they should actually be stored +(in registers or in memory).

  • +
  • Then, replace() is called for each instruction in order to +replace the temporary operands with the previously assigned locations +(and possibly add some instructions before or after). +Concretely, it returns a list of instructions that should replace the original +instruction. The actual iteration over all the instructions is handled transparently +by Lib.LinearCode.LinearCode.iter_statements().

  • +
+
+
+prepare() None[source]
+
+ +
+
+replace(old_instr: Instruction) List[Instruction][source]
+

Transform an instruction with temporaries into a list of instructions.

+
+ +
+
+rewriteCode(listcode) None[source]
+

Modify the code to replace temporaries with +registers or memory locations.

+
+ +
+ +
+
+class Lib.Allocator.NaiveAllocator(fdata: FunctionData)[source]
+

Bases: Allocator

+

Naive Allocator: try to assign a register to each temporary, +fails if there are more temporaries than registers.

+
+
+replace(old_instr: Instruction) List[Instruction][source]
+

Replace Temporary operands with the corresponding allocated Register.

+
+ +
+
+prepare() None[source]
+

Allocate all temporaries to registers. +Fail if there are too many temporaries.

+
+ +
+ +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/api/Lib.Errors.html b/docs/html/api/Lib.Errors.html new file mode 100644 index 0000000..8cc825b --- /dev/null +++ b/docs/html/api/Lib.Errors.html @@ -0,0 +1,151 @@ + + + + + + + Lib.Errors module — MiniC documentation + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Lib.Errors module

+
+
+exception Lib.Errors.MiniCRuntimeError[source]
+

Bases: Exception

+
+ +
+
+exception Lib.Errors.MiniCInternalError[source]
+

Bases: Exception

+
+ +
+
+exception Lib.Errors.MiniCUnsupportedError[source]
+

Bases: Exception

+
+ +
+
+exception Lib.Errors.MiniCTypeError[source]
+

Bases: Exception

+
+ +
+
+exception Lib.Errors.AllocationError[source]
+

Bases: Exception

+
+ +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/api/Lib.FunctionData.html b/docs/html/api/Lib.FunctionData.html new file mode 100644 index 0000000..921f9ed --- /dev/null +++ b/docs/html/api/Lib.FunctionData.html @@ -0,0 +1,178 @@ + + + + + + + Lib.FunctionData module — MiniC documentation + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Lib.FunctionData module

+

This file defines the base class FunctionData, +containing metadata on a RiscV function, as well as utility +functions common to the different intermediate representations.

+
+
+class Lib.FunctionData.FunctionData(name: str)[source]
+

Bases: object

+

Stores some metadata on a RiscV function: +name of the function, label names, temporary variables +(using Lib.Operands.TemporaryPool), +and div_by_zero label.

+

This class is usually used indirectly through the +different intermediate representations we work with, +such as Lib.LinearCode.LinearCode.fdata.

+
+
+get_name() str[source]
+

Return the name of the function.

+
+ +
+
+fresh_tmp() Temporary[source]
+

Return a new fresh Temporary, +which is added to the pool.

+
+ +
+
+fresh_offset() Offset[source]
+

Return a new offset in the memory stack. +Offsets are decreasing relative to FP.

+
+ +
+
+get_offset() int[source]
+

Return the current offset in the memory stack.

+
+ +
+
+fresh_label(name) Label[source]
+

Return a new label, with a unique name based on the given string.

+
+ +
+
+get_label_div_by_zero() Label[source]
+
+ +
+ +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/api/Lib.LinearCode.html b/docs/html/api/Lib.LinearCode.html new file mode 100644 index 0000000..27e7da8 --- /dev/null +++ b/docs/html/api/Lib.LinearCode.html @@ -0,0 +1,200 @@ + + + + + + + Lib.LinearCode module — MiniC documentation + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Lib.LinearCode module

+

CAP, CodeGeneration, LinearCode API +Classes for a RiscV linear code.

+
+
+class Lib.LinearCode.LinearCode(name: str)[source]
+

Bases: object

+

Representation of a RiscV program as a list of instructions.

+

add_instruction() is repeatedly called in the codegen visitor +to build a complete list of RiscV instructions for the source program.

+

The fdata member variable contains some meta-information +on the program, for instance to allocate a new temporary. +See Lib.FunctionData.FunctionData.

+

For debugging purposes, print_code() allows to print +the RiscV program to a file.

+
+
+fdata: FunctionData
+
+ +
+
+add_instruction(i: Comment | Label | Instru3A | AbsoluteJump | ConditionalJump) None[source]
+

Utility function to add an instruction in the program.

+

See also Lib.RiscV to generate relevant instructions.

+
+ +
+
+iter_statements(f) None[source]
+

Iterate over instructions. +For each real instruction i (not label or comment), replace it +with the list of instructions given by f(i).

+
+ +
+
+get_instructions() List[Comment | Label | Instru3A | AbsoluteJump | ConditionalJump][source]
+

Return the list of instructions of the program.

+
+ +
+
+add_label(s: Label) None[source]
+

Add a label in the program.

+
+ +
+
+add_comment(s: str) None[source]
+

Add a comment in the program.

+
+ +
+
+add_instruction_PRINTLN_INT(reg: DataLocation) None[source]
+

Print integer value, with newline. (see Expand)

+
+ +
+
+print_code(output, comment=None) None[source]
+

Outputs the RiscV program as text to a file at the given path.

+
+ +
+
+print_dot(filename: str, DF=None, view=False) None[source]
+

Outputs the RiscV program as graph to a file at the given path.

+
+ +
+ +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/api/Lib.Operands.html b/docs/html/api/Lib.Operands.html new file mode 100644 index 0000000..a5a44f9 --- /dev/null +++ b/docs/html/api/Lib.Operands.html @@ -0,0 +1,390 @@ + + + + + + + Lib.Operands module — MiniC documentation + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Lib.Operands module

+

This file defines the base class Operand +and its subclasses for different operands: Condition, +DataLocation and Function.

+

The class DataLocation itself has subclasses: +Register, Offset for address in memory, +Immediate for constants and Temporary +for location not yet allocated.

+

This file also define shortcuts for registers in RISCV.

+
+
+class Lib.Operands.Operand[source]
+

Bases: object

+
+ +
+
+class Lib.Operands.Condition(optype)[source]
+

Bases: Operand

+

Condition, i.e. comparison operand for a CondJump.

+

Example usage :

+
    +
  • Condition(‘beq’) = branch if equal.

  • +
  • Condition(MiniCParser.LT) = branch if lower than.

  • +
  • +
+

The constructor’s argument shall be a string in the list all_ops, or a +comparison operator in MiniCParser.LT, MiniCParser.GT, … (one of the keys +in opdict).

+

A ‘negate’ method allows getting the negation of this condition.

+
+
+negate() Condition[source]
+

Return the opposite condition.

+
+ +
+ +
+
+class Lib.Operands.Function(name: str)[source]
+

Bases: Operand

+

Operand for build-in function call.

+
+ +
+
+class Lib.Operands.DataLocation[source]
+

Bases: Operand

+

A Data Location is either a register, a temporary +or a place in memory (offset).

+
+ +
+
+class Lib.Operands.Register(number: int)[source]
+

Bases: DataLocation

+

A (physical) register.

+
+ +
+
+Lib.Operands.ZERO = zero
+

Zero register

+
+ +
+
+Lib.Operands.RA = ra
+
+ +
+
+Lib.Operands.SP = sp
+
+ +
+
+Lib.Operands.GP
+

Register not used for this course

+
+ +
+
+Lib.Operands.TP
+

Register not used for this course

+
+ +
+
+Lib.Operands.A = (a0, a1, a2, a3, a4, a5, a6, a7)
+
+ +
+
+Lib.Operands.S = (fp, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11)
+
+ +
+
+Lib.Operands.T = (t0, t1, t2, t3, t4, t5, t6)
+
+ +
+
+Lib.Operands.A0 = a0
+
+ +
+
+Lib.Operands.A1 = a1
+
+ +
+
+Lib.Operands.FP = fp
+

Frame Pointer = Saved register 0

+
+ +
+
+Lib.Operands.GP_REGS = (s4, s5, s6, s7, s8, s9, s10, s11, t0, t1, t2, t3, t4, t5, t6)
+

General purpose registers, usable for the allocator

+
+ +
+
+class Lib.Operands.Offset(basereg: Register, offset: int)[source]
+

Bases: DataLocation

+

Offset = address in memory computed with base + offset.

+
+
+get_offset() int[source]
+

Return the value of the offset.

+
+ +
+ +
+
+class Lib.Operands.Immediate(val)[source]
+

Bases: DataLocation

+

Immediate operand (integer).

+
+ +
+
+class Lib.Operands.Temporary(number: int, pool: TemporaryPool)[source]
+

Bases: DataLocation

+

Temporary, a location that has not been allocated yet. +It will later be mapped to a physical register (Register) or to a memory location (Offset).

+
+
+get_alloced_loc() DataLocation[source]
+

Return the DataLocation allocated to this Temporary.

+
+ +
+ +
+
+class Lib.Operands.TemporaryPool[source]
+

Bases: object

+

Manage a pool of temporaries.

+
+
+get_all_temps() List[Temporary][source]
+

Return all the temporaries of the pool.

+
+ +
+
+get_alloced_loc(t: Temporary) DataLocation[source]
+

Get the actual DataLocation allocated for the temporary t.

+
+ +
+
+add_tmp(t: Temporary)[source]
+

Add a temporary to the pool.

+
+ +
+
+set_temp_allocation(allocation: Dict[Temporary, DataLocation]) None[source]
+

Give a mapping from temporaries to actual registers. +The argument allocation must be a dict from Temporary to +DataLocation other than Temporary (typically Register or Offset). +Typing enforces that keys are Temporary and values are Datalocation. +We check the values are indeed not Temporary.

+
+ +
+
+fresh_tmp() Temporary[source]
+

Give a new fresh Temporary and add it to the pool.

+
+ +
+ +
+
+class Lib.Operands.Renamer(pool: TemporaryPool)[source]
+

Bases: object

+

Manage a renaming of temporaries.

+
+
+fresh(t: Temporary) Temporary[source]
+

Give a fresh rename for a Temporary.

+
+ +
+
+replace(t: Temporary) Temporary[source]
+

Give the rename for a Temporary (which is itself if it is not renamed).

+
+ +
+
+defined(t: Temporary) bool[source]
+

True if the Temporary is renamed.

+
+ +
+
+copy()[source]
+

Give a copy of the Renamer.

+
+ +
+ +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/api/Lib.RiscV.html b/docs/html/api/Lib.RiscV.html new file mode 100644 index 0000000..1a17056 --- /dev/null +++ b/docs/html/api/Lib.RiscV.html @@ -0,0 +1,215 @@ + + + + + + + Lib.RiscV module — MiniC documentation + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Lib.RiscV module

+

MIF08, CAP, CodeGeneration, RiscV API +Functions to define instructions.

+
+
+Lib.RiscV.call(function: Function) Instru3A[source]
+

Function call.

+
+ +
+
+Lib.RiscV.jump(label: Label) AbsoluteJump[source]
+

Unconditional jump to label.

+
+ +
+
+Lib.RiscV.conditional_jump(label: Label, op1: Operand, cond: Condition, op2: Operand)[source]
+

Add a conditional jump to the code. +This is a wrapper around bge, bgt, beq, … c is a Condition, like +Condition(‘bgt’), Condition(MiniCParser.EQ), …

+
+ +
+
+Lib.RiscV.add(dr: Operand, sr1: Operand, sr2orimm7: Operand) Instru3A[source]
+
+ +
+
+Lib.RiscV.mul(dr: Operand, sr1: Operand, sr2orimm7: Operand) Instru3A[source]
+
+ +
+
+Lib.RiscV.div(dr: Operand, sr1: Operand, sr2orimm7: Operand) Instru3A[source]
+
+ +
+
+Lib.RiscV.rem(dr: Operand, sr1: Operand, sr2orimm7: Operand) Instru3A[source]
+
+ +
+
+Lib.RiscV.sub(dr: Operand, sr1: Operand, sr2orimm7: Operand) Instru3A[source]
+
+ +
+
+Lib.RiscV.land(dr: Operand, sr1: Operand, sr2orimm7: Operand) Instru3A[source]
+

And instruction (cannot be called and due to Python and).

+
+ +
+
+Lib.RiscV.lor(dr: Operand, sr1: Operand, sr2orimm7: Operand) Instru3A[source]
+

Or instruction (cannot be called or due to Python or).

+
+ +
+
+Lib.RiscV.xor(dr: Operand, sr1: Operand, sr2orimm7: Operand) Instru3A[source]
+
+ +
+
+Lib.RiscV.li(dr: Operand, imm7: Immediate) Instru3A[source]
+
+ +
+
+Lib.RiscV.mv(dr: Operand, sr: Operand) Instru3A[source]
+
+ +
+
+Lib.RiscV.ld(dr: Operand, mem: Operand) Instru3A[source]
+
+ +
+
+Lib.RiscV.sd(sr: Operand, mem: Operand) Instru3A[source]
+
+ +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/api/Lib.Statement.html b/docs/html/api/Lib.Statement.html new file mode 100644 index 0000000..723f17e --- /dev/null +++ b/docs/html/api/Lib.Statement.html @@ -0,0 +1,442 @@ + + + + + + + Lib.Statement module — MiniC documentation + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Lib.Statement module

+

The base class for RISCV ASM statements is Statement. +It is inherited by Comment, Label +and Instruction. In turn, Instruction +is inherited by Instru3A +(for regular non-branching 3-address instructions), +AbsoluteJump and ConditionalJump.

+
+
+Lib.Statement.regset_to_string(registerset) str[source]
+

Utility function: pretty-prints a set of locations.

+
+ +
+
+class Lib.Statement.Statement[source]
+

Bases: object

+

A Statement, which is an instruction, a comment or a label.

+
+
+defined() List[Operand][source]
+

Operands defined (written) in this instruction

+
+ +
+
+used() List[Operand][source]
+

Operands used (read) in this instruction

+
+ +
+
+substitute(subst: Dict[Operand, Operand]) TStatement[source]
+

Return a new instruction, cloned from this one, replacing operands +that appear as key in subst by their value.

+
+ +
+
+with_args(new_args: List[Operand]) TStatement[source]
+

Return a new instruction, cloned from this one, where operands have +been replaced by new_args.

+
+ +
+
+printIns(stream)[source]
+

Print the statement on the given output. +Should never be called on the base class.

+
+ +
+ +
+
+class Lib.Statement.Comment(comment: str)[source]
+

Bases: Statement

+

A comment.

+
+
+comment: str
+
+ +
+
+printIns(stream)[source]
+

Print the statement on the given output. +Should never be called on the base class.

+
+ +
+ +
+
+class Lib.Statement.Label(name: str)[source]
+

Bases: Statement, Operand

+

A label is both a Statement and an Operand.

+
+
+name: str
+
+ +
+
+printIns(stream)[source]
+

Print the statement on the given output. +Should never be called on the base class.

+
+ +
+ +
+
+class Lib.Statement.Instruction[source]
+

Bases: Statement

+
+
+ins: str
+
+ +
+
+is_read_only()[source]
+

True if the instruction only reads from its operands.

+

Otherwise, the first operand is considered as the destination +and others are source.

+
+ +
+
+rename(renamer: Renamer) None[source]
+
+ +
+
+args() List[Operand][source]
+

List of operands the instruction takes

+
+ +
+
+defined()[source]
+

Operands defined (written) in this instruction

+
+ +
+
+used() List[Operand][source]
+

Operands used (read) in this instruction

+
+ +
+
+printIns(stream)[source]
+

Print the instruction on the given output.

+
+ +
+ +
+
+class Lib.Statement.Instru3A(ins, *args: Lib.Operands.Operand)[source]
+

Bases: Instruction

+
+
+args()[source]
+

List of operands the instruction takes

+
+ +
+
+rename(renamer: Renamer)[source]
+
+ +
+
+substitute(subst: Dict[Operand, Operand])[source]
+

Return a new instruction, cloned from this one, replacing operands +that appear as key in subst by their value.

+
+ +
+
+with_args(new_args: List[Operand])[source]
+

Return a new instruction, cloned from this one, where operands have +been replaced by new_args.

+
+ +
+ +
+
+class Lib.Statement.AbsoluteJump(label: Label)[source]
+

Bases: Instruction

+

An Absolute Jump is a specific kind of instruction

+
+
+ins: str = 'j'
+
+ +
+
+label: Label
+
+ +
+
+args() List[Operand][source]
+

List of operands the instruction takes

+
+ +
+
+rename(renamer: Renamer)[source]
+
+ +
+
+substitute(subst: Dict[Operand, Operand])[source]
+

Return a new instruction, cloned from this one, replacing operands +that appear as key in subst by their value.

+
+ +
+
+with_args(new_args: List[Operand])[source]
+

Return a new instruction, cloned from this one, where operands have +been replaced by new_args.

+
+ +
+
+targets() List[Label][source]
+

Return the labels targetted by the AbsoluteJump.

+
+ +
+ +
+
+class Lib.Statement.ConditionalJump(cond: Condition, op1: Operand, op2: Operand, label: Label)[source]
+

Bases: Instruction

+

A Conditional Jump is a specific kind of instruction

+
+
+cond: Condition
+
+ +
+
+label: Label
+
+ +
+
+op1: Operand
+
+ +
+
+op2: Operand
+
+ +
+
+args()[source]
+

List of operands the instruction takes

+
+ +
+
+rename(renamer: Renamer)[source]
+
+ +
+
+substitute(subst: Dict[Operand, Operand])[source]
+

Return a new instruction, cloned from this one, replacing operands +that appear as key in subst by their value.

+
+ +
+
+with_args(new_args: List[Operand])[source]
+

Return a new instruction, cloned from this one, where operands have +been replaced by new_args.

+
+ +
+ +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/api/Lib.html b/docs/html/api/Lib.html new file mode 100644 index 0000000..ea9a9c5 --- /dev/null +++ b/docs/html/api/Lib.html @@ -0,0 +1,293 @@ + + + + + + + Lib package — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Lib package

+
+

Submodules

+
+ +
+
+
+

Module contents

+
+
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/api/modules.html b/docs/html/api/modules.html new file mode 100644 index 0000000..27a146f --- /dev/null +++ b/docs/html/api/modules.html @@ -0,0 +1,195 @@ + + + + + + + MiniC — MiniC documentation + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/html/genindex.html b/docs/html/genindex.html new file mode 100644 index 0000000..fa6069e --- /dev/null +++ b/docs/html/genindex.html @@ -0,0 +1,618 @@ + + + + + + Index — MiniC documentation + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + +
  • +
  • +
+
+
+
+
+ + +

Index

+ +
+ A + | C + | D + | F + | G + | I + | J + | L + | M + | N + | O + | P + | R + | S + | T + | U + | W + | X + | Z + +
+

A

+ + + +
+ +

C

+ + + +
+ +

D

+ + + +
+ +

F

+ + + +
+ +

G

+ + + +
+ +

I

+ + + +
+ +

J

+ + +
+ +

L

+ + + +
+ +

M

+ + + +
+ +

N

+ + + +
+ +

O

+ + + +
+ +

P

+ + + +
+ +

R

+ + + +
+ +

S

+ + + +
+ +

T

+ + + +
+ +

U

+ + +
+ +

W

+ + +
+ +

X

+ + +
+ +

Z

+ + +
+ + + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/index.html b/docs/html/index.html new file mode 100644 index 0000000..55dc096 --- /dev/null +++ b/docs/html/index.html @@ -0,0 +1,335 @@ + + + + + + + Welcome to MiniC’s documentation! — MiniC documentation + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Welcome to MiniC’s documentation!

+
+

Contents:

+ +
+

These pages document the various Python sources in the Lib/ +folder of MiniC. You should not have to edit them at all.

+
+

Base library

+

The Lib.Statement module defines various classes that represent +RISC-V assembly statements, such as labels or 3-address instructions.

+

We won’t create objects of these classes directly very often. +Instead, to easily create such statements for standard RISC-V assembly instructions +and pseudo-instructions, we give you the Lib.RiscV module.

+

RISC-V instructions take arguments of various kinds, +as defined in the Lib.Operands module.

+

At some point, we will need some basic functions about oriented and non oriented graphs, +those are present in api/Lib.Graphes.

+
+
+

Linear Intermediate representation

+

The Lib.LinearCode module allows to work with assembly source code +modeled as a list of statements.

+
+
+

Temporary allocation

+

Before implementing the all-in-memory allocator of lab 4a, +you should understand the naive allocator in the Lib.Allocator module.

+
+
+

Control Flow Graph Intermediate representation

+

The classes for the CFG and its basic blocks are in the api/Lib.CFG. +Each block ends with a terminator, as documented in the api/Lib.Terminator.

+
+
+

SSA form

+

The translation of the CFG into SSA form makes use of dominance frontiers. +Functions to work with dominance are defined in the api/Lib.Dominators.

+

Phi nodes, a special kind of statement that appears in CFGs in SSA form, +are defined in the api/Lib.PhiNode.

+
+
+
+

Indices and tables

+ +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/objects.inv b/docs/html/objects.inv new file mode 100644 index 0000000..b111a63 Binary files /dev/null and b/docs/html/objects.inv differ diff --git a/docs/html/py-modindex.html b/docs/html/py-modindex.html new file mode 100644 index 0000000..ffa52c4 --- /dev/null +++ b/docs/html/py-modindex.html @@ -0,0 +1,160 @@ + + + + + + Python Module Index — MiniC documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + +
  • +
  • +
+
+
+
+
+ + +

Python Module Index

+ +
+ l +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
+ l
+ Lib +
    + Lib.Allocator +
    + Lib.Errors +
    + Lib.FunctionData +
    + Lib.LinearCode +
    + Lib.Operands +
    + Lib.RiscV +
    + Lib.Statement +
+ + +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/html/search.html b/docs/html/search.html new file mode 100644 index 0000000..8fc86f1 --- /dev/null +++ b/docs/html/search.html @@ -0,0 +1,125 @@ + + + + + + Search — MiniC documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + +
  • +
  • +
+
+
+
+
+ + + + +
+ +
+ +
+
+ +
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/docs/html/searchindex.js b/docs/html/searchindex.js new file mode 100644 index 0000000..e8d30af --- /dev/null +++ b/docs/html/searchindex.js @@ -0,0 +1 @@ +Search.setIndex({"docnames": ["api/Lib", "api/Lib.Allocator", "api/Lib.Errors", "api/Lib.FunctionData", "api/Lib.LinearCode", "api/Lib.Operands", "api/Lib.RiscV", "api/Lib.Statement", "api/modules", "index"], "filenames": ["api/Lib.rst", "api/Lib.Allocator.rst", "api/Lib.Errors.rst", "api/Lib.FunctionData.rst", "api/Lib.LinearCode.rst", "api/Lib.Operands.rst", "api/Lib.RiscV.rst", "api/Lib.Statement.rst", "api/modules.rst", "index.rst"], "titles": ["Lib package", "Lib.Allocator module", "Lib.Errors module", "Lib.FunctionData module", "Lib.LinearCode module", "Lib.Operands module", "Lib.RiscV module", "Lib.Statement module", "MiniC", "Welcome to MiniC\u2019s documentation!"], "terms": {"alloc": [0, 4, 5, 8], "prepar": [0, 1, 9], "replac": [0, 1, 4, 5, 7, 9], "rewritecod": [0, 1, 9], "naivealloc": [0, 1, 8, 9], "error": [0, 8, 9], "minicruntimeerror": [0, 2, 8, 9], "minicinternalerror": [0, 2, 8, 9], "minicunsupportederror": [0, 2, 8, 9], "minictypeerror": [0, 2, 8, 9], "allocationerror": [0, 2, 8, 9], "functiondata": [0, 1, 4, 8, 9], "get_nam": [0, 3, 9], "fresh_tmp": [0, 3, 5, 9], "fresh_offset": [0, 3, 9], "get_offset": [0, 3, 5, 9], "fresh_label": [0, 3, 9], "get_label_div_by_zero": [0, 3, 9], "linearcod": [0, 1, 3, 8, 9], "fdata": [0, 1, 3, 4, 9], "add_instruct": [0, 4, 9], "iter_stat": [0, 1, 4, 9], "get_instruct": [0, 4, 9], "add_label": [0, 4, 9], "add_com": [0, 4, 9], "add_instruction_println_int": [0, 4, 9], "print_cod": [0, 4, 9], "print_dot": [0, 4, 9], "operand": [0, 1, 3, 6, 7, 8, 9], "condit": [0, 5, 6, 7, 8, 9], "negat": [0, 5, 9], "function": [0, 3, 4, 5, 6, 7, 8, 9], "dataloc": [0, 4, 5, 8, 9], "regist": [0, 1, 5, 8, 9], "zero": [0, 5, 8, 9], "ra": [0, 5, 8, 9], "sp": [0, 5, 8, 9], "gp": [0, 5, 8, 9], "tp": [0, 5, 8, 9], "A": [0, 5, 7, 8, 9], "": [0, 4, 5, 8], "t": [0, 5, 8, 9], "a0": [0, 5, 8, 9], "a1": [0, 5, 8, 9], "fp": [0, 3, 5, 8, 9], "gp_reg": [0, 5, 8, 9], "offset": [0, 3, 5, 8, 9], "immedi": [0, 5, 6, 8, 9], "temporari": [0, 1, 3, 4, 5, 8], "get_alloced_loc": [0, 5, 9], "temporarypool": [0, 1, 3, 5, 8, 9], "get_all_temp": [0, 5, 9], "add_tmp": [0, 5, 9], "set_temp_alloc": [0, 1, 5, 9], "renam": [0, 5, 7, 8, 9], "fresh": [0, 3, 5, 9], "defin": [0, 1, 3, 5, 6, 7, 9], "copi": [0, 5, 9], "riscv": [0, 3, 4, 5, 7, 8, 9], "call": [0, 1, 4, 5, 6, 7, 8, 9], "jump": [0, 6, 7, 8, 9], "conditional_jump": [0, 6, 8, 9], "add": [0, 1, 4, 5, 6, 8, 9], "mul": [0, 6, 8, 9], "div": [0, 6, 8, 9], "rem": [0, 6, 8, 9], "sub": [0, 6, 8, 9], "land": [0, 6, 8, 9], "lor": [0, 6, 8, 9], "xor": [0, 6, 8, 9], "li": [0, 6, 8, 9], "mv": [0, 6, 8, 9], "ld": [0, 6, 8, 9], "sd": [0, 6, 8, 9], "statement": [0, 8, 9], "regset_to_str": [0, 7, 8, 9], "us": [0, 3, 5, 7, 9], "substitut": [0, 7, 9], "with_arg": [0, 7, 9], "printin": [0, 7, 9], "comment": [0, 4, 7, 8, 9], "label": [0, 3, 4, 6, 7, 8, 9], "name": [0, 3, 4, 5, 7, 9], "instruct": [0, 1, 4, 6, 7, 8, 9], "ins": [0, 7, 9], "is_read_onli": [0, 7, 9], "arg": [0, 7, 9], "instru3a": [0, 4, 6, 7, 8, 9], "absolutejump": [0, 4, 6, 7, 8, 9], "target": [0, 7, 9], "conditionaljump": [0, 4, 7, 8, 9], "cond": [0, 6, 7, 9], "op1": [0, 6, 7, 9], "op2": [0, 6, 7, 9], "thi": [1, 3, 5, 6, 7], "file": [1, 3, 4, 5], "base": [1, 2, 3, 4, 5, 7], "class": [1, 3, 4, 5, 7, 9], "na\u00efv": 1, "implement": [1, 9], "sourc": [1, 2, 3, 4, 5, 6, 7, 9], "object": [1, 3, 4, 5, 7, 9], "gener": [1, 4, 5], "naiv": [1, 9], "allinmem": 1, "smart": 1, "all": [1, 5, 9], "code": [1, 4, 6, 9], "actual": [1, 5], "data": [1, 5, 9], "locat": [1, 5, 7], "i": [1, 3, 4, 5, 6, 7], "done": 1, "two": 1, "step": 1, "first": [1, 7], "respons": 1, "map": [1, 5], "from": [1, 5, 7], "where": [1, 7], "thei": 1, "should": [1, 7, 9], "store": [1, 3], "memori": [1, 3, 5, 9], "Then": 1, "each": [1, 4, 9], "order": 1, "previous": 1, "assign": 1, "possibli": 1, "some": [1, 3, 4, 9], "befor": [1, 9], "after": 1, "concret": 1, "return": [1, 3, 4, 5, 7], "list": [1, 4, 5, 7, 9], "origin": 1, "The": [1, 4, 5, 7, 9], "iter": [1, 4], "over": [1, 4], "handl": 1, "transpar": 1, "none": [1, 4, 5, 7], "old_instr": 1, "transform": 1, "an": [1, 4, 7], "listcod": 1, "modifi": 1, "try": 1, "fail": 1, "ar": [1, 3, 5, 7, 9], "more": 1, "than": [1, 5], "correspond": 1, "too": 1, "mani": 1, "except": 2, "contain": [3, 4], "metadata": 3, "well": 3, "util": [3, 4, 7], "common": 3, "differ": [3, 5], "intermedi": 3, "represent": [3, 4], "str": [3, 4, 5, 7], "variabl": [3, 4], "div_by_zero": 3, "usual": 3, "indirectli": 3, "through": 3, "we": [3, 5, 9], "work": [3, 9], "new": [3, 4, 5, 7], "which": [3, 5, 7], "ad": 3, "pool": [3, 5], "stack": 3, "decreas": 3, "rel": 3, "int": [3, 5], "current": 3, "uniqu": 3, "given": [3, 4, 7], "string": [3, 5], "cap": [4, 6], "codegener": [4, 6], "api": [4, 6, 9], "linear": 4, "program": 4, "repeatedli": 4, "codegen": 4, "visitor": 4, "build": [4, 5], "complet": 4, "member": 4, "meta": 4, "inform": 4, "instanc": 4, "see": 4, "For": 4, "debug": 4, "purpos": [4, 5], "allow": [4, 5, 9], "print": [4, 7], "also": [4, 5], "relev": 4, "f": 4, "real": 4, "reg": 4, "integ": [4, 5], "valu": [4, 5, 7], "newlin": 4, "expand": 4, "output": [4, 7], "text": 4, "path": 4, "filenam": 4, "df": 4, "view": 4, "fals": 4, "graph": 4, "its": [5, 7, 9], "subclass": 5, "itself": 5, "ha": 5, "address": [5, 7, 9], "constant": 5, "yet": 5, "shortcut": 5, "optyp": 5, "e": 5, "comparison": 5, "condjump": 5, "exampl": 5, "usag": 5, "beq": [5, 6], "branch": [5, 7], "equal": 5, "minicpars": [5, 6], "lt": 5, "lower": 5, "constructor": 5, "argument": [5, 9], "shall": 5, "all_op": 5, "oper": 5, "gt": 5, "one": [5, 7], "kei": [5, 7], "opdict": 5, "method": 5, "get": 5, "opposit": 5, "either": 5, "place": 5, "number": 5, "physic": 5, "cours": 5, "a2": 5, "a3": 5, "a4": 5, "a5": 5, "a6": 5, "a7": 5, "s1": 5, "s2": 5, "s3": 5, "s4": 5, "s5": 5, "s6": 5, "s7": 5, "s8": 5, "s9": 5, "s10": 5, "s11": 5, "t0": 5, "t1": 5, "t2": 5, "t3": 5, "t4": 5, "t5": 5, "t6": 5, "frame": 5, "pointer": 5, "save": 5, "0": 5, "usabl": 5, "basereg": 5, "comput": 5, "val": 5, "been": [5, 7], "It": [5, 7], "later": 5, "manag": 5, "dict": [5, 7], "give": [5, 9], "must": 5, "other": [5, 7], "typic": 5, "type": 5, "enforc": 5, "check": 5, "inde": 5, "bool": 5, "true": [5, 7], "mif08": 6, "uncondit": 6, "wrapper": 6, "around": 6, "bge": 6, "bgt": 6, "c": 6, "like": 6, "eq": 6, "dr": 6, "sr1": 6, "sr2orimm7": 6, "And": 6, "cannot": 6, "due": 6, "python": [6, 9], "Or": 6, "imm7": 6, "sr": 6, "mem": 6, "asm": 7, "inherit": 7, "In": 7, "turn": 7, "regular": 7, "non": [7, 9], "3": [7, 9], "registerset": 7, "pretti": 7, "set": 7, "written": 7, "read": 7, "subst": 7, "tstatement": 7, "clone": 7, "appear": [7, 9], "new_arg": 7, "have": [7, 9], "stream": 7, "never": 7, "both": 7, "onli": 7, "otherwis": 7, "consid": 7, "destin": 7, "take": [7, 9], "absolut": 7, "specif": 7, "kind": [7, 9], "j": 7, "lib": [8, 9], "packag": 8, "submodul": 8, "modul": [8, 9], "content": 8, "risc": 9, "v": 9, "These": 9, "page": 9, "variou": 9, "folder": 9, "you": 9, "edit": 9, "them": 9, "repres": 9, "assembli": 9, "won": 9, "creat": 9, "directli": 9, "veri": 9, "often": 9, "instead": 9, "easili": 9, "standard": 9, "pseudo": 9, "At": 9, "point": 9, "need": 9, "basic": 9, "about": 9, "orient": 9, "those": 9, "present": 9, "model": 9, "lab": 9, "4a": 9, "understand": 9, "cfg": 9, "block": 9, "end": 9, "termin": 9, "translat": 9, "make": 9, "domin": 9, "frontier": 9, "phi": 9, "node": 9, "special": 9, "phinod": 9, "index": 9, "search": 9}, "objects": {"": [[0, 0, 0, "-", "Lib"]], "Lib": [[1, 0, 0, "-", "Allocator"], [2, 0, 0, "-", "Errors"], [3, 0, 0, "-", "FunctionData"], [4, 0, 0, "-", "LinearCode"], [5, 0, 0, "-", "Operands"], [6, 0, 0, "-", "RiscV"], [7, 0, 0, "-", "Statement"]], "Lib.Allocator": [[1, 1, 1, "", "Allocator"], [1, 1, 1, "", "NaiveAllocator"]], "Lib.Allocator.Allocator": [[1, 2, 1, "", "prepare"], [1, 2, 1, "", "replace"], [1, 2, 1, "", "rewriteCode"]], "Lib.Allocator.NaiveAllocator": [[1, 2, 1, "", "prepare"], [1, 2, 1, "", "replace"]], "Lib.Errors": [[2, 3, 1, "", "AllocationError"], [2, 3, 1, "", "MiniCInternalError"], [2, 3, 1, "", "MiniCRuntimeError"], [2, 3, 1, "", "MiniCTypeError"], [2, 3, 1, "", "MiniCUnsupportedError"]], "Lib.FunctionData": [[3, 1, 1, "", "FunctionData"]], "Lib.FunctionData.FunctionData": [[3, 2, 1, "", "fresh_label"], [3, 2, 1, "", "fresh_offset"], [3, 2, 1, "", "fresh_tmp"], [3, 2, 1, "", "get_label_div_by_zero"], [3, 2, 1, "", "get_name"], [3, 2, 1, "", "get_offset"]], "Lib.LinearCode": [[4, 1, 1, "", "LinearCode"]], "Lib.LinearCode.LinearCode": [[4, 2, 1, "", "add_comment"], [4, 2, 1, "", "add_instruction"], [4, 2, 1, "", "add_instruction_PRINTLN_INT"], [4, 2, 1, "", "add_label"], [4, 4, 1, "", "fdata"], [4, 2, 1, "", "get_instructions"], [4, 2, 1, "", "iter_statements"], [4, 2, 1, "", "print_code"], [4, 2, 1, "", "print_dot"]], "Lib.Operands": [[5, 5, 1, "", "A"], [5, 5, 1, "", "A0"], [5, 5, 1, "", "A1"], [5, 1, 1, "", "Condition"], [5, 1, 1, "", "DataLocation"], [5, 5, 1, "", "FP"], [5, 1, 1, "", "Function"], [5, 5, 1, "", "GP"], [5, 5, 1, "", "GP_REGS"], [5, 1, 1, "", "Immediate"], [5, 1, 1, "", "Offset"], [5, 1, 1, "", "Operand"], [5, 5, 1, "", "RA"], [5, 1, 1, "", "Register"], [5, 1, 1, "", "Renamer"], [5, 5, 1, "", "S"], [5, 5, 1, "", "SP"], [5, 5, 1, "", "T"], [5, 5, 1, "", "TP"], [5, 1, 1, "", "Temporary"], [5, 1, 1, "", "TemporaryPool"], [5, 5, 1, "", "ZERO"]], "Lib.Operands.Condition": [[5, 2, 1, "", "negate"]], "Lib.Operands.Offset": [[5, 2, 1, "", "get_offset"]], "Lib.Operands.Renamer": [[5, 2, 1, "", "copy"], [5, 2, 1, "", "defined"], [5, 2, 1, "", "fresh"], [5, 2, 1, "", "replace"]], "Lib.Operands.Temporary": [[5, 2, 1, "", "get_alloced_loc"]], "Lib.Operands.TemporaryPool": [[5, 2, 1, "", "add_tmp"], [5, 2, 1, "", "fresh_tmp"], [5, 2, 1, "", "get_all_temps"], [5, 2, 1, "", "get_alloced_loc"], [5, 2, 1, "", "set_temp_allocation"]], "Lib.RiscV": [[6, 6, 1, "", "add"], [6, 6, 1, "", "call"], [6, 6, 1, "", "conditional_jump"], [6, 6, 1, "", "div"], [6, 6, 1, "", "jump"], [6, 6, 1, "", "land"], [6, 6, 1, "", "ld"], [6, 6, 1, "", "li"], [6, 6, 1, "", "lor"], [6, 6, 1, "", "mul"], [6, 6, 1, "", "mv"], [6, 6, 1, "", "rem"], [6, 6, 1, "", "sd"], [6, 6, 1, "", "sub"], [6, 6, 1, "", "xor"]], "Lib.Statement": [[7, 1, 1, "", "AbsoluteJump"], [7, 1, 1, "", "Comment"], [7, 1, 1, "", "ConditionalJump"], [7, 1, 1, "", "Instru3A"], [7, 1, 1, "", "Instruction"], [7, 1, 1, "", "Label"], [7, 1, 1, "", "Statement"], [7, 6, 1, "", "regset_to_string"]], "Lib.Statement.AbsoluteJump": [[7, 2, 1, "", "args"], [7, 4, 1, "", "ins"], [7, 4, 1, "", "label"], [7, 2, 1, "", "rename"], [7, 2, 1, "", "substitute"], [7, 2, 1, "", "targets"], [7, 2, 1, "", "with_args"]], "Lib.Statement.Comment": [[7, 4, 1, "", "comment"], [7, 2, 1, "", "printIns"]], "Lib.Statement.ConditionalJump": [[7, 2, 1, "", "args"], [7, 4, 1, "", "cond"], [7, 4, 1, "", "label"], [7, 4, 1, "", "op1"], [7, 4, 1, "", "op2"], [7, 2, 1, "", "rename"], [7, 2, 1, "", "substitute"], [7, 2, 1, "", "with_args"]], "Lib.Statement.Instru3A": [[7, 2, 1, "", "args"], [7, 2, 1, "", "rename"], [7, 2, 1, "", "substitute"], [7, 2, 1, "", "with_args"]], "Lib.Statement.Instruction": [[7, 2, 1, "", "args"], [7, 2, 1, "", "defined"], [7, 4, 1, "", "ins"], [7, 2, 1, "", "is_read_only"], [7, 2, 1, "", "printIns"], [7, 2, 1, "", "rename"], [7, 2, 1, "", "used"]], "Lib.Statement.Label": [[7, 4, 1, "", "name"], [7, 2, 1, "", "printIns"]], "Lib.Statement.Statement": [[7, 2, 1, "", "defined"], [7, 2, 1, "", "printIns"], [7, 2, 1, "", "substitute"], [7, 2, 1, "", "used"], [7, 2, 1, "", "with_args"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:method", "3": "py:exception", "4": "py:attribute", "5": "py:data", "6": "py:function"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "method", "Python method"], "3": ["py", "exception", "Python exception"], "4": ["py", "attribute", "Python attribute"], "5": ["py", "data", "Python data"], "6": ["py", "function", "Python function"]}, "titleterms": {"lib": [0, 1, 2, 3, 4, 5, 6, 7], "packag": 0, "submodul": 0, "modul": [0, 1, 2, 3, 4, 5, 6, 7], "content": [0, 9], "alloc": [1, 9], "error": 2, "functiondata": 3, "linearcod": 4, "operand": 5, "riscv": 6, "statement": 7, "minic": [8, 9], "welcom": 9, "": 9, "document": 9, "base": 9, "librari": 9, "linear": 9, "intermedi": 9, "represent": 9, "temporari": 9, "control": 9, "flow": 9, "graph": 9, "ssa": 9, "form": 9, "indic": 9, "tabl": 9}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1, "sphinx": 57}, "alltitles": {"Lib package": [[0, "lib-package"]], "Submodules": [[0, "submodules"]], "Module contents": [[0, "module-Lib"]], "Lib.Allocator module": [[1, "module-Lib.Allocator"]], "Lib.Errors module": [[2, "module-Lib.Errors"]], "Lib.FunctionData module": [[3, "module-Lib.FunctionData"]], "Lib.LinearCode module": [[4, "module-Lib.LinearCode"]], "Lib.Operands module": [[5, "module-Lib.Operands"]], "Lib.RiscV module": [[6, "module-Lib.RiscV"]], "Lib.Statement module": [[7, "module-Lib.Statement"]], "MiniC": [[8, "minic"]], "Welcome to MiniC\u2019s documentation!": [[9, "welcome-to-minic-s-documentation"]], "Contents:": [[9, null]], "Base library": [[9, "base-library"]], "Linear Intermediate representation": [[9, "linear-intermediate-representation"]], "Temporary allocation": [[9, "temporary-allocation"]], "Control Flow Graph Intermediate representation": [[9, "control-flow-graph-intermediate-representation"]], "SSA form": [[9, "ssa-form"]], "Indices and tables": [[9, "indices-and-tables"]]}, "indexentries": {"lib": [[0, "module-Lib"]], "module": [[0, "module-Lib"], [1, "module-Lib.Allocator"], [2, "module-Lib.Errors"], [3, "module-Lib.FunctionData"], [4, "module-Lib.LinearCode"], [5, "module-Lib.Operands"], [6, "module-Lib.RiscV"], [7, "module-Lib.Statement"]], "allocator (class in lib.allocator)": [[1, "Lib.Allocator.Allocator"]], "lib.allocator": [[1, "module-Lib.Allocator"]], "naiveallocator (class in lib.allocator)": [[1, "Lib.Allocator.NaiveAllocator"]], "prepare() (lib.allocator.allocator method)": [[1, "Lib.Allocator.Allocator.prepare"]], "prepare() (lib.allocator.naiveallocator method)": [[1, "Lib.Allocator.NaiveAllocator.prepare"]], "replace() (lib.allocator.allocator method)": [[1, "Lib.Allocator.Allocator.replace"]], "replace() (lib.allocator.naiveallocator method)": [[1, "Lib.Allocator.NaiveAllocator.replace"]], "rewritecode() (lib.allocator.allocator method)": [[1, "Lib.Allocator.Allocator.rewriteCode"]], "allocationerror": [[2, "Lib.Errors.AllocationError"]], "lib.errors": [[2, "module-Lib.Errors"]], "minicinternalerror": [[2, "Lib.Errors.MiniCInternalError"]], "minicruntimeerror": [[2, "Lib.Errors.MiniCRuntimeError"]], "minictypeerror": [[2, "Lib.Errors.MiniCTypeError"]], "minicunsupportederror": [[2, "Lib.Errors.MiniCUnsupportedError"]], "functiondata (class in lib.functiondata)": [[3, "Lib.FunctionData.FunctionData"]], "lib.functiondata": [[3, "module-Lib.FunctionData"]], "fresh_label() (lib.functiondata.functiondata method)": [[3, "Lib.FunctionData.FunctionData.fresh_label"]], "fresh_offset() (lib.functiondata.functiondata method)": [[3, "Lib.FunctionData.FunctionData.fresh_offset"]], "fresh_tmp() (lib.functiondata.functiondata method)": [[3, "Lib.FunctionData.FunctionData.fresh_tmp"]], "get_label_div_by_zero() (lib.functiondata.functiondata method)": [[3, "Lib.FunctionData.FunctionData.get_label_div_by_zero"]], "get_name() (lib.functiondata.functiondata method)": [[3, "Lib.FunctionData.FunctionData.get_name"]], "get_offset() (lib.functiondata.functiondata method)": [[3, "Lib.FunctionData.FunctionData.get_offset"]], "lib.linearcode": [[4, "module-Lib.LinearCode"]], "linearcode (class in lib.linearcode)": [[4, "Lib.LinearCode.LinearCode"]], "add_comment() (lib.linearcode.linearcode method)": [[4, "Lib.LinearCode.LinearCode.add_comment"]], "add_instruction() (lib.linearcode.linearcode method)": [[4, "Lib.LinearCode.LinearCode.add_instruction"]], "add_instruction_println_int() (lib.linearcode.linearcode method)": [[4, "Lib.LinearCode.LinearCode.add_instruction_PRINTLN_INT"]], "add_label() (lib.linearcode.linearcode method)": [[4, "Lib.LinearCode.LinearCode.add_label"]], "fdata (lib.linearcode.linearcode attribute)": [[4, "Lib.LinearCode.LinearCode.fdata"]], "get_instructions() (lib.linearcode.linearcode method)": [[4, "Lib.LinearCode.LinearCode.get_instructions"]], "iter_statements() (lib.linearcode.linearcode method)": [[4, "Lib.LinearCode.LinearCode.iter_statements"]], "print_code() (lib.linearcode.linearcode method)": [[4, "Lib.LinearCode.LinearCode.print_code"]], "print_dot() (lib.linearcode.linearcode method)": [[4, "Lib.LinearCode.LinearCode.print_dot"]], "a (in module lib.operands)": [[5, "Lib.Operands.A"]], "a0 (in module lib.operands)": [[5, "Lib.Operands.A0"]], "a1 (in module lib.operands)": [[5, "Lib.Operands.A1"]], "condition (class in lib.operands)": [[5, "Lib.Operands.Condition"]], "datalocation (class in lib.operands)": [[5, "Lib.Operands.DataLocation"]], "fp (in module lib.operands)": [[5, "Lib.Operands.FP"]], "function (class in lib.operands)": [[5, "Lib.Operands.Function"]], "gp (in module lib.operands)": [[5, "Lib.Operands.GP"]], "gp_regs (in module lib.operands)": [[5, "Lib.Operands.GP_REGS"]], "immediate (class in lib.operands)": [[5, "Lib.Operands.Immediate"]], "lib.operands": [[5, "module-Lib.Operands"]], "offset (class in lib.operands)": [[5, "Lib.Operands.Offset"]], "operand (class in lib.operands)": [[5, "Lib.Operands.Operand"]], "ra (in module lib.operands)": [[5, "Lib.Operands.RA"]], "register (class in lib.operands)": [[5, "Lib.Operands.Register"]], "renamer (class in lib.operands)": [[5, "Lib.Operands.Renamer"]], "s (in module lib.operands)": [[5, "Lib.Operands.S"]], "sp (in module lib.operands)": [[5, "Lib.Operands.SP"]], "t (in module lib.operands)": [[5, "Lib.Operands.T"]], "tp (in module lib.operands)": [[5, "Lib.Operands.TP"]], "temporary (class in lib.operands)": [[5, "Lib.Operands.Temporary"]], "temporarypool (class in lib.operands)": [[5, "Lib.Operands.TemporaryPool"]], "zero (in module lib.operands)": [[5, "Lib.Operands.ZERO"]], "add_tmp() (lib.operands.temporarypool method)": [[5, "Lib.Operands.TemporaryPool.add_tmp"]], "copy() (lib.operands.renamer method)": [[5, "Lib.Operands.Renamer.copy"]], "defined() (lib.operands.renamer method)": [[5, "Lib.Operands.Renamer.defined"]], "fresh() (lib.operands.renamer method)": [[5, "Lib.Operands.Renamer.fresh"]], "fresh_tmp() (lib.operands.temporarypool method)": [[5, "Lib.Operands.TemporaryPool.fresh_tmp"]], "get_all_temps() (lib.operands.temporarypool method)": [[5, "Lib.Operands.TemporaryPool.get_all_temps"]], "get_alloced_loc() (lib.operands.temporary method)": [[5, "Lib.Operands.Temporary.get_alloced_loc"]], "get_alloced_loc() (lib.operands.temporarypool method)": [[5, "Lib.Operands.TemporaryPool.get_alloced_loc"]], "get_offset() (lib.operands.offset method)": [[5, "Lib.Operands.Offset.get_offset"]], "negate() (lib.operands.condition method)": [[5, "Lib.Operands.Condition.negate"]], "replace() (lib.operands.renamer method)": [[5, "Lib.Operands.Renamer.replace"]], "set_temp_allocation() (lib.operands.temporarypool method)": [[5, "Lib.Operands.TemporaryPool.set_temp_allocation"]], "lib.riscv": [[6, "module-Lib.RiscV"]], "add() (in module lib.riscv)": [[6, "Lib.RiscV.add"]], "call() (in module lib.riscv)": [[6, "Lib.RiscV.call"]], "conditional_jump() (in module lib.riscv)": [[6, "Lib.RiscV.conditional_jump"]], "div() (in module lib.riscv)": [[6, "Lib.RiscV.div"]], "jump() (in module lib.riscv)": [[6, "Lib.RiscV.jump"]], "land() (in module lib.riscv)": [[6, "Lib.RiscV.land"]], "ld() (in module lib.riscv)": [[6, "Lib.RiscV.ld"]], "li() (in module lib.riscv)": [[6, "Lib.RiscV.li"]], "lor() (in module lib.riscv)": [[6, "Lib.RiscV.lor"]], "mul() (in module lib.riscv)": [[6, "Lib.RiscV.mul"]], "mv() (in module lib.riscv)": [[6, "Lib.RiscV.mv"]], "rem() (in module lib.riscv)": [[6, "Lib.RiscV.rem"]], "sd() (in module lib.riscv)": [[6, "Lib.RiscV.sd"]], "sub() (in module lib.riscv)": [[6, "Lib.RiscV.sub"]], "xor() (in module lib.riscv)": [[6, "Lib.RiscV.xor"]], "absolutejump (class in lib.statement)": [[7, "Lib.Statement.AbsoluteJump"]], "comment (class in lib.statement)": [[7, "Lib.Statement.Comment"]], "conditionaljump (class in lib.statement)": [[7, "Lib.Statement.ConditionalJump"]], "instru3a (class in lib.statement)": [[7, "Lib.Statement.Instru3A"]], "instruction (class in lib.statement)": [[7, "Lib.Statement.Instruction"]], "label (class in lib.statement)": [[7, "Lib.Statement.Label"]], "lib.statement": [[7, "module-Lib.Statement"]], "statement (class in lib.statement)": [[7, "Lib.Statement.Statement"]], "args() (lib.statement.absolutejump method)": [[7, "Lib.Statement.AbsoluteJump.args"]], "args() (lib.statement.conditionaljump method)": [[7, "Lib.Statement.ConditionalJump.args"]], "args() (lib.statement.instru3a method)": [[7, "Lib.Statement.Instru3A.args"]], "args() (lib.statement.instruction method)": [[7, "Lib.Statement.Instruction.args"]], "comment (lib.statement.comment attribute)": [[7, "Lib.Statement.Comment.comment"]], "cond (lib.statement.conditionaljump attribute)": [[7, "Lib.Statement.ConditionalJump.cond"]], "defined() (lib.statement.instruction method)": [[7, "Lib.Statement.Instruction.defined"]], "defined() (lib.statement.statement method)": [[7, "Lib.Statement.Statement.defined"]], "ins (lib.statement.absolutejump attribute)": [[7, "Lib.Statement.AbsoluteJump.ins"]], "ins (lib.statement.instruction attribute)": [[7, "Lib.Statement.Instruction.ins"]], "is_read_only() (lib.statement.instruction method)": [[7, "Lib.Statement.Instruction.is_read_only"]], "label (lib.statement.absolutejump attribute)": [[7, "Lib.Statement.AbsoluteJump.label"]], "label (lib.statement.conditionaljump attribute)": [[7, "Lib.Statement.ConditionalJump.label"]], "name (lib.statement.label attribute)": [[7, "Lib.Statement.Label.name"]], "op1 (lib.statement.conditionaljump attribute)": [[7, "Lib.Statement.ConditionalJump.op1"]], "op2 (lib.statement.conditionaljump attribute)": [[7, "Lib.Statement.ConditionalJump.op2"]], "printins() (lib.statement.comment method)": [[7, "Lib.Statement.Comment.printIns"]], "printins() (lib.statement.instruction method)": [[7, "Lib.Statement.Instruction.printIns"]], "printins() (lib.statement.label method)": [[7, "Lib.Statement.Label.printIns"]], "printins() (lib.statement.statement method)": [[7, "Lib.Statement.Statement.printIns"]], "regset_to_string() (in module lib.statement)": [[7, "Lib.Statement.regset_to_string"]], "rename() (lib.statement.absolutejump method)": [[7, "Lib.Statement.AbsoluteJump.rename"]], "rename() (lib.statement.conditionaljump method)": [[7, "Lib.Statement.ConditionalJump.rename"]], "rename() (lib.statement.instru3a method)": [[7, "Lib.Statement.Instru3A.rename"]], "rename() (lib.statement.instruction method)": [[7, "Lib.Statement.Instruction.rename"]], "substitute() (lib.statement.absolutejump method)": [[7, "Lib.Statement.AbsoluteJump.substitute"]], "substitute() (lib.statement.conditionaljump method)": [[7, "Lib.Statement.ConditionalJump.substitute"]], "substitute() (lib.statement.instru3a method)": [[7, "Lib.Statement.Instru3A.substitute"]], "substitute() (lib.statement.statement method)": [[7, "Lib.Statement.Statement.substitute"]], "targets() (lib.statement.absolutejump method)": [[7, "Lib.Statement.AbsoluteJump.targets"]], "used() (lib.statement.instruction method)": [[7, "Lib.Statement.Instruction.used"]], "used() (lib.statement.statement method)": [[7, "Lib.Statement.Statement.used"]], "with_args() (lib.statement.absolutejump method)": [[7, "Lib.Statement.AbsoluteJump.with_args"]], "with_args() (lib.statement.conditionaljump method)": [[7, "Lib.Statement.ConditionalJump.with_args"]], "with_args() (lib.statement.instru3a method)": [[7, "Lib.Statement.Instru3A.with_args"]], "with_args() (lib.statement.statement method)": [[7, "Lib.Statement.Statement.with_args"]]}}) \ No newline at end of file