source: icGREP/icgrep-devel/icgrep/pablo/pe_xor.cpp @ 4388

Last change on this file since 4388 was 4247, checked in by cameron, 5 years ago

All -> Zeroes, Ones

File size: 828 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 <pablo/pe_xor.h>
8#include <pablo/codegenstate.h>
9
10namespace pablo {
11
12PabloAST * OptimizeXor::operator()(PabloAST * expr1, PabloAST * expr2) {
13    if (isa<Ones>(expr1)) {
14        return cg.createNot(expr2);
15    }
16    else if (isa<Zeroes>(expr1)){
17        return expr2;       
18    }
19    else if (isa<Ones>(expr2)) {
20        return cg.createNot(expr1);
21    }
22    else if (isa<Zeroes>(expr2)){
23        return expr1;
24    }
25    else if (Not * not1 = dyn_cast<Not>(expr1)) {
26        if (Not * not2 = dyn_cast<Not>(expr2)) {
27            return cg.createXor(not1->getExpr(), not2->getExpr());
28        }
29    }
30    return new Xor(expr1, expr2);
31}
32
33}
Note: See TracBrowser for help on using the repository browser.