source: icGREP/icgrep-devel/icgrep/pablo/pe_xor.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: 943 bytes
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_xor.h"
8#include "pe_all.h"
9#include "pe_not.h"
10
11namespace pablo {
12
13PabloE * make_xor(PabloE * expr1, PabloE * expr2) {
14    if (All * all1 = dyn_cast<All>(expr1)) {
15        if (all1->getValue()) {
16            return make_not(expr2);
17        }
18        else {
19            return expr2;
20        }
21    }
22    else if (All* all2 = dyn_cast<All>(expr2)) {
23        if (all2->getValue() == 1) {
24            return make_not(expr1);
25        }
26        else { //if (all_expr2->getNum() == 0)
27            return expr1;
28        }
29    }
30    else if (Not * not1 = dyn_cast<Not>(expr1)) {
31        if (Not * not2 = dyn_cast<Not>(expr2)) {
32            return make_xor(not1->getExpr(), not2->getExpr());
33        }
34    }
35    return new Xor(expr1, expr2);
36}
37
38}
Note: See TracBrowser for help on using the repository browser.