Rename lisp-like functions as suggested by Gabor Greif as loooong time

ago.  This is both easier to learn and easier to read.

llvm-svn: 123001
This commit is contained in:
David Greene 2011-01-07 17:05:37 +00:00
parent f30101186f
commit 2f7cf7fcb4
10 changed files with 41 additions and 41 deletions

View File

@ -412,11 +412,11 @@ be an object defined by a 'def' construct.</dd>
<dd>For each member 'b' of dag or list 'a' apply operator 'c.' 'b' is a
dummy variable that should be declared as a member variable of an instantiated
class. This operation is analogous to $(foreach) in GNU make.</dd>
<dt><tt>!car(a)</tt></dt>
<dt><tt>!head(a)</tt></dt>
<dd>The first element of list 'a.'</dd>
<dt><tt>!cdr(a)</tt></dt>
<dt><tt>!tail(a)</tt></dt>
<dd>The 2nd-N elements of list 'a.'</dd>
<dt><tt>!null(a)</tt></dt>
<dt><tt>!empty(a)</tt></dt>
<dd>An integer {0,1} indicating whether list 'a' is empty.</dd>
<dt><tt>!if(a,b,c)</tt></dt>
<dd>'b' if the result of 'int' or 'bit' operator 'a' is nonzero,

View File

@ -7,6 +7,6 @@ class Bli<string _t>
}
class Bla<list<Bli> _bli>
: Bli<!car(_bli).t>
: Bli<!head(_bli).t>
{
}

View File

@ -66,19 +66,19 @@ def not : SDNode;
multiclass scalar<bits<8> opcode, string asmstr = "", list<list<dag>> patterns = []> {
def SSrr : Inst<opcode, (outs FR32:$dst), (ins FR32:$src),
!strconcat(asmstr, "\t$dst, $src"),
!if(!null(patterns),[]<dag>,patterns[0])>;
!if(!empty(patterns),[]<dag>,patterns[0])>;
def SSrm : Inst<opcode, (outs FR32:$dst), (ins FR32:$src),
!strconcat(asmstr, "\t$dst, $src"),
!if(!null(patterns),[]<dag>,!if(!null(!cdr(patterns)),patterns[0],patterns[1]))>;
!if(!empty(patterns),[]<dag>,!if(!empty(!tail(patterns)),patterns[0],patterns[1]))>;
}
multiclass vscalar<bits<8> opcode, string asmstr = "", list<list<dag>> patterns = []> {
def V#NAME#SSrr : Inst<opcode, (outs FR32:$dst), (ins FR32:$src),
!strconcat(asmstr, "\t$dst, $src"),
!if(!null(patterns),[]<dag>,patterns[0])>;
!if(!empty(patterns),[]<dag>,patterns[0])>;
def V#NAME#SSrm : Inst<opcode, (outs FR32:$dst), (ins FR32:$src),
!strconcat(asmstr, "\t$dst, $src"),
!if(!null(patterns),[]<dag>,!if(!null(!cdr(patterns)),patterns[0],patterns[1]))>;
!if(!empty(patterns),[]<dag>,!if(!empty(!tail(patterns)),patterns[0],patterns[1]))>;
}
multiclass myscalar<bits<8> opcode, string asmstr = "", list<list<dag>> patterns = []> :

View File

@ -28,7 +28,7 @@ class C<bits<3> x, bits<4> y, bit z> {
class A<list<list<int>> vals> {
list<int> first = vals[0];
list<int> rest = !if(!null(!cdr(vals)), vals[0], vals[1]);
list<int> rest = !if(!empty(!tail(vals)), vals[0], vals[1]);
}
def One : A<[[1,2,3]]>;
@ -38,7 +38,7 @@ class B<list<int> v> {
list<int> vals = v;
}
class BB<list<list<int>> vals> : B<!if(!null(!cdr(vals)), vals[0], vals[1])>;
class BB<list<list<int>> vals> : B<!if(!empty(!tail(vals)), vals[0], vals[1])>;
class BBB<list<list<int>> vals> : BB<vals>;
def OneB : BBB<[[1,2,3]]>;

View File

@ -15,7 +15,7 @@ class CDR<list<string> r, int n> {
}
class NameList<list<string> Names> :
List<Names>, CAR<!car(Names)>, CDR<!cdr(Names), !null(!cdr(Names))>;
List<Names>, CAR<!head(Names)>, CDR<!tail(Names), !empty(!tail(Names))>;
def Three : NameList<["Tom", "Dick", "Harry"]>;

View File

@ -590,7 +590,7 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
}
break;
}
case CAR: {
case HEAD: {
ListInit *LHSl = dynamic_cast<ListInit*>(LHS);
if (LHSl) {
if (LHSl->getSize() == 0) {
@ -601,7 +601,7 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
}
break;
}
case CDR: {
case TAIL: {
ListInit *LHSl = dynamic_cast<ListInit*>(LHS);
if (LHSl) {
if (LHSl->getSize() == 0) {
@ -614,7 +614,7 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
}
break;
}
case LNULL: {
case EMPTY: {
ListInit *LHSl = dynamic_cast<ListInit*>(LHS);
if (LHSl) {
if (LHSl->getSize() == 0) {
@ -650,9 +650,9 @@ std::string UnOpInit::getAsString() const {
std::string Result;
switch (Opc) {
case CAST: Result = "!cast<" + getType()->getAsString() + ">"; break;
case CAR: Result = "!car"; break;
case CDR: Result = "!cdr"; break;
case LNULL: Result = "!null"; break;
case HEAD: Result = "!head"; break;
case TAIL: Result = "!tail"; break;
case EMPTY: Result = "!empty"; break;
}
return Result + "(" + LHS->getAsString() + ")";
}

View File

@ -811,7 +811,7 @@ public:
///
class UnOpInit : public OpInit {
public:
enum UnaryOp { CAST, CAR, CDR, LNULL };
enum UnaryOp { CAST, HEAD, TAIL, EMPTY };
private:
UnaryOp Opc;
Init *LHS;

View File

@ -424,14 +424,14 @@ tgtok::TokKind TGLexer::LexExclaim() {
StringSwitch<tgtok::TokKind>(StringRef(Start, CurPtr - Start))
.Case("eq", tgtok::XEq)
.Case("if", tgtok::XIf)
.Case("car", tgtok::XCar)
.Case("cdr", tgtok::XCdr)
.Case("head", tgtok::XHead)
.Case("tail", tgtok::XTail)
.Case("con", tgtok::XConcat)
.Case("shl", tgtok::XSHL)
.Case("sra", tgtok::XSRA)
.Case("srl", tgtok::XSRL)
.Case("cast", tgtok::XCast)
.Case("null", tgtok::XNull)
.Case("empty", tgtok::XEmpty)
.Case("subst", tgtok::XSubst)
.Case("foreach", tgtok::XForEach)
.Case("strconcat", tgtok::XStrConcat)

View File

@ -46,7 +46,7 @@ namespace tgtok {
// !keywords.
XConcat, XSRA, XSRL, XSHL, XStrConcat, XCast, XSubst,
XForEach, XCar, XCdr, XNull, XIf, XEq,
XForEach, XHead, XTail, XEmpty, XIf, XEq,
// Integer value.
IntVal,

View File

@ -683,9 +683,9 @@ Init *TGParser::ParseOperation(Record *CurRec) {
TokError("unknown operation");
return 0;
break;
case tgtok::XCar:
case tgtok::XCdr:
case tgtok::XNull:
case tgtok::XHead:
case tgtok::XTail:
case tgtok::XEmpty:
case tgtok::XCast: { // Value ::= !unop '(' Value ')'
UnOpInit::UnaryOp Code;
RecTy *Type = 0;
@ -704,17 +704,17 @@ Init *TGParser::ParseOperation(Record *CurRec) {
}
break;
case tgtok::XCar:
case tgtok::XHead:
Lex.Lex(); // eat the operation
Code = UnOpInit::CAR;
Code = UnOpInit::HEAD;
break;
case tgtok::XCdr:
case tgtok::XTail:
Lex.Lex(); // eat the operation
Code = UnOpInit::CDR;
Code = UnOpInit::TAIL;
break;
case tgtok::XNull:
case tgtok::XEmpty:
Lex.Lex(); // eat the operation
Code = UnOpInit::LNULL;
Code = UnOpInit::EMPTY;
Type = new IntRecTy;
break;
}
@ -727,9 +727,9 @@ Init *TGParser::ParseOperation(Record *CurRec) {
Init *LHS = ParseValue(CurRec);
if (LHS == 0) return 0;
if (Code == UnOpInit::CAR
|| Code == UnOpInit::CDR
|| Code == UnOpInit::LNULL) {
if (Code == UnOpInit::HEAD
|| Code == UnOpInit::TAIL
|| Code == UnOpInit::EMPTY) {
ListInit *LHSl = dynamic_cast<ListInit*>(LHS);
StringInit *LHSs = dynamic_cast<StringInit*>(LHS);
TypedInit *LHSt = dynamic_cast<TypedInit*>(LHS);
@ -746,8 +746,8 @@ Init *TGParser::ParseOperation(Record *CurRec) {
}
}
if (Code == UnOpInit::CAR
|| Code == UnOpInit::CDR) {
if (Code == UnOpInit::HEAD
|| Code == UnOpInit::TAIL) {
if (LHSl == 0 && LHSt == 0) {
TokError("expected list type argumnet in unary operator");
return 0;
@ -764,7 +764,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
TokError("untyped list element in unary operator");
return 0;
}
if (Code == UnOpInit::CAR) {
if (Code == UnOpInit::HEAD) {
Type = Itemt->getType();
} else {
Type = new ListRecTy(Itemt->getType());
@ -776,7 +776,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
TokError("expected list type argumnet in unary operator");
return 0;
}
if (Code == UnOpInit::CAR) {
if (Code == UnOpInit::HEAD) {
Type = LType->getElementType();
} else {
Type = LType;
@ -1273,9 +1273,9 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
return new DagInit(Operator, OperatorName, DagArgs);
}
case tgtok::XCar:
case tgtok::XCdr:
case tgtok::XNull:
case tgtok::XHead:
case tgtok::XTail:
case tgtok::XEmpty:
case tgtok::XCast: // Value ::= !unop '(' Value ')'
case tgtok::XConcat:
case tgtok::XSRA: