Radicalc  Check-in [863a252f75]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added intrinsincs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:863a252f75869039eb88e054973ae45dad173d0eb55872e7b7cb58bbc9b63290
User & Date: athaudia 2017-08-01 14:18:39
Context
2017-08-01
16:21
intrinsic stubs in seperate file check-in: bbec39aeac user: athaudia tags: trunk
14:18
added intrinsincs check-in: 863a252f75 user: athaudia tags: trunk
14:16
added intrinsincs check-in: 5bcf572b20 user: athaudia tags: trunk
Changes

Changes to src/llvm.js.

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
		});
	});
}

function outNode(out, node) {
	switch(node.type) {
		case 'funCall':
			/*if(node.name == 'add') {
				out.write(tmp);
				out.write(" = add ");
				outDataType(out, params[0][1]);
				out.write(" ");
				out.write(params[0][0]);
				out.write(", ");
				out.write(params[1][0]);
				out.write("\n");
			} else if(node.name == 'mul') {
				out.write(tmp);
				out.write(" = mul ");
				outDataType(out, params[0][1]);
				out.write(" ");
				out.write(params[0][0]);
				out.write(", ");
				out.write(params[1][0]);
				out.write("\n");
			} else if(node.name == 'is_less_or_eq') {
				out.write(tmp);
				out.write(" = icmp sle "); //todo: signed vs unsigned
				outDataType(out, params[0][1]);
				out.write(" ");
				out.write(params[0][0]);
				out.write(", ");
				out.write(params[1][0]);
				out.write("\n");
			} else */

			var dts = node.params.map((param) => { return param.dataType });
			var intrinsicFunc = getIntrinsic(node.name, dts);
			if(intrinsicFunc) {
				var params = node.params.map((param) => {
					return outNode(out, param);
				});
				return intrinsicFunc(out, params);
................................................................................
			//return llvmDataTypeStr(node.dataType) + " " + node.val;
			return node.val;
		case 'varUse':
			if(node.var.isParam) {
				return varStr(node.var);
			}
			var tmp = newTmp();
			out.write("  ");
			out.write(tmp);
			out.write(" = load ");
			outDataType(out, node.dataType);
			out.write(", ");
			outDataType(out, node.dataType);
			out.write("* ");
			outVar(out, node.var);
			out.write("\n");
			return tmp;
		default:
			out.write("  ; ")
			out.write(node.type);
			out.write(" node not yet implemented\n");







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|
<
<
|
|
<
<







118
119
120
121
122
123
124





























125
126
127
128
129
130
131
...
155
156
157
158
159
160
161
162


163
164


165
166
167
168
169
170
171
		});
	});
}

function outNode(out, node) {
	switch(node.type) {
		case 'funCall':





























			var dts = node.params.map((param) => { return param.dataType });
			var intrinsicFunc = getIntrinsic(node.name, dts);
			if(intrinsicFunc) {
				var params = node.params.map((param) => {
					return outNode(out, param);
				});
				return intrinsicFunc(out, params);
................................................................................
			//return llvmDataTypeStr(node.dataType) + " " + node.val;
			return node.val;
		case 'varUse':
			if(node.var.isParam) {
				return varStr(node.var);
			}
			var tmp = newTmp();
			out.write("  " + tmp + " = load ");


			var dt = dataTypeStr(node.dataType);
			out.write(dt + ", " + dt + "* ");


			outVar(out, node.var);
			out.write("\n");
			return tmp;
		default:
			out.write("  ; ")
			out.write(node.type);
			out.write(" node not yet implemented\n");