Created
June 13, 2012 22:00
-
-
Save sehe/2926754 to your computer and use it in GitHub Desktop.
counterexample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "Register.hpp" | |
int main(int argc, const char * argv[]) | |
{ | |
std::cout << rax << " " << rbx << std::endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all:main | |
CPPFLAGS+=-std=c++0x | |
CPPFLAGS+=-g -O2 | |
CPPFLAGS+=-march=native | |
%:%.cpp | |
g++ $(CPPFLAGS) -c $M -o $@ $^ | |
.depends: *.cpp | |
g++ $(CPPFLAGS) $^ -M > $@ | |
-include .depends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Register.hpp **/ | |
#ifndef lss_Register_hpp | |
#define lss_Register_hpp | |
#include <string> | |
#include <ostream> | |
enum RegisterFlag { CPU }; | |
struct Register | |
{ | |
const int uniqueId; | |
const std::string name; | |
const enum RegisterFlag flag; | |
Register(int uniqueId, std::string name, enum RegisterFlag flag) : uniqueId(uniqueId), name(name), flag(flag) {} | |
Register() = delete; | |
}; | |
std::ostream & operator << (std::ostream &os, const Register ®) | |
{ | |
return (os << reg.name); | |
} | |
const Register rax(0, "rax", CPU); | |
const Register rcx(1, "rcx", CPU); | |
const Register rdx(2, "rdx", CPU); | |
const Register rbx(3, "rbx", CPU); | |
const Register rsp(3, "rsp", CPU); | |
const Register rbp(3, "rbp", CPU); | |
const Register rsi(3, "rsi", CPU); | |
const Register rdi(3, "rdi", CPU); | |
const Register r8(3, "r8", CPU); | |
const Register r9(3, "r9", CPU); | |
const Register r10(3, "r10", CPU); | |
const Register r11(3, "r11", CPU); | |
const Register r12(3, "r12", CPU); | |
const Register r13(3, "r13", CPU); | |
const Register r14(3, "r14", CPU); | |
const Register r15(3, "r15", CPU); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment