Home | History | Annotate | Download | only in seccomp-bpf

Lines Matching refs:CodeGen

9 #include "sandbox/linux/seccomp-bpf/codegen.h"
22 class CodeGenUnittestHelper : public CodeGen {
26 CodeGen::FindBranchTargets(instructions, branch_targets);
32 return CodeGen::CutGraphIntoBasicBlocks(insns, branch_targets, blocks);
36 CodeGen::MergeTails(blocks);
44 Instruction *SampleProgramOneInstruction(CodeGen *codegen, int *flags) {
48 return codegen->MakeInstruction(BPF_RET+BPF_K,
52 Instruction *SampleProgramSimpleBranch(CodeGen *codegen, int *flags) {
58 return codegen->MakeInstruction(BPF_JMP+BPF_JEQ+BPF_K, 42,
59 codegen->MakeInstruction(BPF_RET+BPF_K,
61 codegen->MakeInstruction(BPF_RET+BPF_K,
65 Instruction *SampleProgramAtypicalBranch(CodeGen *codegen, int *flags) {
76 codegen->MakeInstruction(BPF_RET+BPF_K,
78 return codegen->MakeInstruction(BPF_JMP+BPF_JEQ+BPF_K, 42, ret, ret);
81 Instruction *SampleProgramComplex(CodeGen *codegen, int *flags) {
93 Instruction *insn0 = codegen->MakeInstruction(BPF_LD+BPF_W+BPF_ABS, 42);
99 Instruction *insn1 = codegen->MakeInstruction(BPF_JMP+BPF_JA, 0, insn0);
104 Instruction *insn2 = codegen->MakeInstruction(BPF_RET+BPF_K, ErrorCode(42));
111 Instruction *insn3 = codegen->MakeInstruction(BPF_LD+BPF_W+BPF_ABS, 42,
112 codegen->MakeInstruction(BPF_RET+BPF_K, ErrorCode(42)));
114 Instruction *insn4 = codegen->MakeInstruction(BPF_JMP+BPF_JEQ+BPF_K, 42,
122 codegen->JoinInstructions(insn0, insn2);
125 Instruction *insn5 = codegen->MakeInstruction(BPF_LD+BPF_W+BPF_ABS,
138 Instruction *insn6 = codegen->MakeInstruction(BPF_JMP+BPF_JEQ+BPF_K, 42,
145 Instruction *(*function_table[])(CodeGen *codegen, int *flags) = {
153 CodeGenUnittestHelper codegen;
155 Instruction *prg = function_table[i](&codegen, &flags);
156 test(&codegen, prg, flags);
160 void MakeInstruction(CodeGenUnittestHelper *codegen,
165 SANDBOX_TEST(CodeGen, MakeInstruction) {
169 void FindBranchTargets(CodeGenUnittestHelper *codegen, Instruction *prg, int) {
171 codegen->FindBranchTargets(*prg, &branch_targets);
226 SANDBOX_TEST(CodeGen, FindBranchTargets) {
230 void CutGraphIntoBasicBlocks(CodeGenUnittestHelper *codegen,
233 codegen->FindBranchTargets(*prg, &branch_targets);
236 codegen->CutGraphIntoBasicBlocks(prg, branch_targets, &all_blocks);
271 SANDBOX_TEST(CodeGen, CutGraphIntoBasicBlocks) {
275 void MergeTails(CodeGenUnittestHelper *codegen, Instruction *prg,
278 codegen->FindBranchTargets(*prg, &branch_targets);
281 codegen->CutGraphIntoBasicBlocks(prg, branch_targets, &all_blocks);
346 codegen->MergeTails(&all_blocks);
356 SANDBOX_TEST(CodeGen, MergeTails) {
360 void CompileAndCompare(CodeGenUnittestHelper *codegen, Instruction *prg, int) {
407 codegen->Compile(prg, &bpf);
441 SANDBOX_TEST(CodeGen, All) {