#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_container.hpp>
#include <boost/spirit/include/phoenix_bind.hpp>
#include <boost/timer.hpp>
#include <stdio.h>
#include <assert.h>
#include <string>
#include <vector>
#include "xbyak/xbyak.h"
Go to the source code of this file.
|
| template<class Func > |
| void | Test (const char *msg, const Func &f) |
| |
| int | main (int argc, char *argv[]) |
| |
◆ XBYAK_NO_OP_NAMES
| #define XBYAK_NO_OP_NAMES |
◆ CodeSet
◆ Operand
| Enumerator |
|---|
| OpAdd | |
| OpSub | |
| OpMul | |
| OpDiv | |
| OpNeg | |
| OpImm | |
| OpVarX | |
Definition at line 28 of file calc2.cpp.
◆ main()
| int main |
( |
int | argc, |
|
|
char * | argv[] ) |
Definition at line 267 of file calc2.cpp.
268{
269 if (argc < 2) {
270 fprintf(stderr, "input formula\n");
271 return 1;
272 }
273 const std::string
str(
argv[1]);
274
275 try {
279
280 const std::string::const_iterator end =
str.end();
281
282 std::string::const_iterator i =
str.begin();
283 if (!phrase_parse(i, end, parser, boost::spirit::ascii::space) || i != end) {
284 puts("err 1");
285 return 1;
286 }
287 printf(
"ret=%f\n", vm(2.3));
288
290 if (!phrase_parse(i, end, parserJit, boost::spirit::ascii::space) || i != end) {
291 puts("err 2");
292 return 1;
293 }
295 double (*jit)(double) = parserJit.
code_.
getCode<double (*)(double)>();
296
299 } catch (...) {
300 fprintf(stderr, "err\n");
301 }
302}
void Test(const char *msg, const Func &f)
const uint8 * getCode() const
LOGGING_API void printf(Category category, const char *format,...)
◆ Test()
| void Test |
( |
const char * | msg, |
|
|
const Func & | f ) |
Definition at line 256 of file calc2.cpp.
257{
259 boost::timer t;
260 double sum = 0;
261 for (double x = 0; x < 1000; x += 0.0001) {
263 }
264 printf(
"sum=%f, %fsec\n", sum, t.elapsed());
265}