source: icGREP/icgrep-devel/icgrep/pablo/pe_sel.cpp @ 4200

Last change on this file since 4200 was 4200, checked in by nmedfort, 5 years ago

Replaced dynamic_cast with llvm::dyn_cast in pablo code; implemented make functions for pablo constructors. Disabled RTTI.

File size: 1.1 KB
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include "pe_sel.h"
8#include "pe_all.h"
9#include "pe_and.h"
10#include "pe_or.h"
11#include "pe_not.h"
12
13namespace pablo {
14
15PabloE * make_sel(PabloE * if_expr, PabloE * t_expr, PabloE * f_expr) {
16    if (All * all_if_expr = dyn_cast<All>(if_expr)) {
17        if (all_if_expr->getValue()) {
18            return t_expr;
19        }
20        else {
21            return f_expr;
22        }
23    }
24    else if (All * all_t_expr = dyn_cast<All>(t_expr)) {
25        if (all_t_expr->getValue()) {
26            return make_or(if_expr, f_expr);
27        }
28        else {
29            return make_and(make_not(if_expr), f_expr);
30        }
31    }
32    else if (All * all_f_expr = dyn_cast<All>(f_expr)) {
33        if (all_f_expr->getValue()) {
34            return make_or(make_not(if_expr), t_expr);
35        }
36        else {
37            return make_and(if_expr, t_expr);
38        }
39    }
40    else if (equals(t_expr, f_expr)) {
41        return t_expr;
42    }
43    return new Sel(if_expr, t_expr, f_expr);
44}
45
46}
Note: See TracBrowser for help on using the repository browser.